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. Hidden Date Display Widget for Admin by andrew.schoen 4 years, 9 months ago
  2. Admin Image Widget + easy-thumbnails by babu 2 years, 10 months ago
  3. Custom admin widgets by field type by dgouldin 5 years, 1 month ago
  4. Custom CheckboxSelectMultiple by martync 4 years, 6 months ago
  5. Django using admin horizontal filter in forms by crodjer 2 years, 10 months ago

Comments

(Forgotten your password?)