Ticket #17165: trunk.diff
File trunk.diff, 1.9 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/forms/tests/extra.py
10 10 from django.forms.util import ErrorList 11 11 from django.utils import translation, unittest 12 12 from django.utils.encoding import force_unicode, smart_unicode 13 from django.utils.formats import get_format 13 14 14 15 from .error_messages import AssertFormErrorsMixin 15 16 … … 697 698 w = SelectDateWidget(years=('1899',)) 698 699 self.assertEqual(w.value_from_datadict({'date_year': '1899', 'date_month': '8', 'date_day': '13'}, {}, 'date'), '13-08-1899') 699 700 701 # _has_changed works correctly with a localized date format 702 input_format = get_format('DATE_INPUT_FORMATS')[0] 703 today = datetime.date.today() 704 today_l10n = today.strftime(input_format) 705 tomorrow = today + datetime.timedelta(days=1) 706 self.assertEqual(w._has_changed(today, today_l10n), False) 707 self.assertEqual(w._has_changed(tomorrow, today_l10n), True) 708 700 709 def test_l10n_invalid_date_in(self): 701 710 # Invalid dates shouldn't be allowed 702 711 a = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'}) -
django/forms/extras/widgets.py
134 134 s = Select(choices=choices) 135 135 select_html = s.render(field % name, val, local_attrs) 136 136 return select_html 137 138 def _has_changed(self, initial, data): 139 input_format = get_format('DATE_INPUT_FORMATS')[0] 140 data = datetime_safe.datetime.strptime(data, input_format).date() 141 return super(SelectDateWidget, self)._has_changed(initial, data)