Ticket #17165: 1.3.X.diff
File 1.3.X.diff, 1.8 KB (added by , 13 years ago) |
---|
-
django/forms/extras/widgets.py
139 139 s = Select(choices=choices) 140 140 select_html = s.render(field % name, val, local_attrs) 141 141 return select_html 142 143 def _has_changed(self, initial, data): 144 input_format = get_format('DATE_INPUT_FORMATS')[0] 145 data = datetime_safe.datetime(*(time.strptime(data, input_format)[0:6])).date() 146 return super(SelectDateWidget, self)._has_changed(initial, data) -
tests/regressiontests/forms/tests/extra.py
9 9 from django.utils import unittest 10 10 from django.utils.encoding import force_unicode 11 11 from django.utils.encoding import smart_unicode 12 from django.utils.formats import get_format 12 13 from error_messages import AssertFormErrorsMixin 13 14 14 15 class GetDate(Form): … … 610 611 <option value="2016">2016</option> 611 612 </select>""") 612 613 614 # _has_changed works correctly with a localized date format 615 input_format = get_format('DATE_INPUT_FORMATS')[0] 616 today = datetime.date.today() 617 today_l10n = today.strftime(input_format) 618 tomorrow = today + datetime.timedelta(days=1) 619 self.assertEqual(w._has_changed(today, today_l10n), False) 620 self.assertEqual(w._has_changed(tomorrow, today_l10n), True) 621 613 622 # Years before 1900 work 614 623 w = SelectDateWidget(years=('1899',)) 615 624 self.assertEqual(w.value_from_datadict({'date_year': '1899', 'date_month': '8', 'date_day': '13'}, {}, 'date'), '13-08-1899')