Code

Ticket #7656: patch_django_7656.20090209.diff

File patch_django_7656.20090209.diff, 1.2 KB (added by david, 5 years ago)

Patch against r9820, AdminTimeWidget inherit from TimeInput and not DateTimeInput

Line 
1Index: django/contrib/admin/widgets.py
2===================================================================
3--- django/contrib/admin/widgets.py     (revision 9820)
4+++ django/contrib/admin/widgets.py     (working copy)
5@@ -39,15 +39,18 @@
6             (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX))
7         return mark_safe(u''.join(output))
8 
9-class AdminDateWidget(forms.TextInput):
10+class AdminDateWidget(forms.DateTimeInput):
11+    format = getattr(settings, 'ADMIN_DATE_FORMAT', '%Y-%m-%d')
12+   
13     class Media:
14         js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
15               settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
16 
17-    def __init__(self, attrs={}):
18-        super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'})
19+    def __init__(self, attrs={}, format=None):
20+        super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format)
21 
22-class AdminTimeWidget(forms.TextInput):
23+class AdminTimeWidget(forms.TimeInput):
24+   
25     class Media:
26         js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
27               settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")