Custom Times for the Django Admin Time Widget

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{% extends "admin/change_form.html" %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript">
django.jQuery(window).load(function() {
    django.jQuery('.timelist').each(function(num, el) {
        time_format = get_format('TIME_INPUT_FORMATS')[0];
        django.jQuery(el).html('');
        for (i=8; i<20; i++) {
          var time = new Date(1970,1,1,i,0,0);
          lnk = "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '" + time.strftime(time_format) + "');"
          /*django.jQuery(el).append('<li><a href="'lnk'">' + time.strftime('%H:%M') + '</a></li>');*/
          django.jQuery(el).append('<li><a href="' + lnk + '">' + time.strftime(time_format) + '</a></li>');
        }

    });
});
</script>
{% endblock %}

More like this

  1. Dynamically change admin widgets at runtime by davisd 3 years, 1 month ago
  2. Javascript Chain Select Widget by ogo 4 years, 11 months ago
  3. Custom color field with Javascript color picker by seanl 4 years, 10 months ago
  4. SelectDateWidget by silent1mezzo 2 years, 5 months ago
  5. Admin Save and view next button html by ungenio41 3 years ago

Comments

(Forgotten your password?)