Fixed #26533 -- Renamed Widget._format_value() to format_value().

This commit is contained in:
Tim Graham 2016-04-23 13:15:45 -04:00
parent 669c29c8f4
commit 859eeaa0f0
7 changed files with 107 additions and 81 deletions

View File

@ -376,7 +376,7 @@ class AdminURLFieldWidget(forms.URLInput):
def render(self, name, value, attrs=None):
html = super(AdminURLFieldWidget, self).render(name, value, attrs)
if value:
value = force_text(self._format_value(value))
value = force_text(self.format_value(value))
final_attrs = {'href': smart_urlquote(value)}
html = format_html(
'<p class="url">{} <a{}>{}</a><br />{} {}</p>',

View File

@ -15,6 +15,9 @@ from django.templatetags.static import static
from django.utils import datetime_safe, formats, six
from django.utils.datastructures import MultiValueDict
from django.utils.dates import MONTHS
from django.utils.deprecation import (
RemovedInDjango20Warning, RenameMethodsBase,
)
from django.utils.encoding import (
force_str, force_text, python_2_unicode_compatible,
)
@ -174,7 +177,13 @@ class SubWidget(object):
return self.parent_widget.render(*args)
class Widget(six.with_metaclass(MediaDefiningClass)):
class RenameWidgetMethods(MediaDefiningClass, RenameMethodsBase):
renamed_methods = (
('_format_value', 'format_value', RemovedInDjango20Warning),
)
class Widget(six.with_metaclass(RenameWidgetMethods)):
needs_multipart_form = False # Determines does this widget need multipart form
is_localized = False
is_required = False
@ -248,7 +257,7 @@ class Input(Widget):
"""
input_type = None # Subclasses must define this.
def _format_value(self, value):
def format_value(self, value):
if self.is_localized:
return formats.localize_input(value)
return value
@ -259,7 +268,7 @@ class Input(Widget):
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_text(self._format_value(value))
final_attrs['value'] = force_text(self.format_value(value))
return format_html('<input{} />', flatatt(final_attrs))
@ -443,7 +452,7 @@ class DateTimeBaseInput(TextInput):
super(DateTimeBaseInput, self).__init__(attrs)
self.format = format if format else None
def _format_value(self, value):
def format_value(self, value):
return formats.localize_input(value, self.format or formats.get_format(self.format_key)[0])

View File

@ -163,6 +163,8 @@ details on these changes.
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
``parent_link`` will be removed.
* Support for ``Widget._format_value()`` will be removed.
.. _deprecation-removed-in-1.10:
1.10

View File

@ -228,6 +228,17 @@ foundation for custom widgets.
In older versions, this attribute was only defined on the date
and time widgets (as ``False``).
.. method:: format_value(value)
Cleans and returns a value for use in the widget template. ``value``
isn't guaranteed to be valid input, therefore subclass implementations
should program defensively.
.. versionchanged:: 1.10
In older versions, this method is a private API named
``_format_value()``. The old name will work until Django 2.0.
.. method:: id_for_label(self, id_)
Returns the HTML ID attribute of this widget for use by a ``<label>``,

View File

@ -983,6 +983,10 @@ Miscellaneous
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
``parent_link`` is deprecated. Add ``parent_link=True`` to such fields.
* The private API ``Widget._format_value()`` is made public and renamed to
:meth:`~django.forms.Widget.format_value`. The old name will work
through a deprecation period.
.. _removed-features-1.10:
Features removed in 1.10

View File

@ -69,7 +69,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year': '2008',
'mydate_month': '4',
'mydate_day': '1',
'initial-mydate': HiddenInput()._format_value(date(2008, 4, 1)),
'initial-mydate': HiddenInput().format_value(date(2008, 4, 1)),
}, initial={'mydate': date(2008, 4, 1)})
self.assertFalse(b.has_changed())
@ -77,7 +77,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year': '2008',
'mydate_month': '4',
'mydate_day': '22',
'initial-mydate': HiddenInput()._format_value(date(2008, 4, 1)),
'initial-mydate': HiddenInput().format_value(date(2008, 4, 1)),
}, initial={'mydate': date(2008, 4, 1)})
self.assertTrue(b.has_changed())
@ -85,7 +85,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year': '2008',
'mydate_month': '4',
'mydate_day': '22',
'initial-mydate': HiddenInput()._format_value(date(2008, 4, 1)),
'initial-mydate': HiddenInput().format_value(date(2008, 4, 1)),
}, initial={'mydate': date(2008, 4, 22)})
self.assertTrue(b.has_changed())
@ -93,7 +93,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year': '2008',
'mydate_month': '4',
'mydate_day': '22',
'initial-mydate': HiddenInput()._format_value(date(2008, 4, 22)),
'initial-mydate': HiddenInput().format_value(date(2008, 4, 22)),
}, initial={'mydate': date(2008, 4, 1)})
self.assertFalse(b.has_changed())

View File

@ -27,7 +27,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '13:30:05')
# Parse a time in a valid, but non-default format, get a parsed result
@ -35,7 +35,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
# ISO formats are accepted, even if not specified in formats.py
@ -54,7 +54,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '13:30:05')
# Parse a time in a valid format, get a parsed result
@ -62,7 +62,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
def test_timeField_with_inputformat(self):
@ -79,7 +79,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid format, get a parsed result
@ -87,7 +87,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
def test_localized_timeField_with_inputformat(self):
@ -104,7 +104,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid format, get a parsed result
@ -112,7 +112,7 @@ class LocalizedTimeTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
@ -130,7 +130,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '01:30:05 PM')
# Parse a time in a valid, but non-default format, get a parsed result
@ -138,7 +138,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM")
def test_localized_timeField(self):
@ -153,7 +153,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '01:30:05 PM')
# Parse a time in a valid format, get a parsed result
@ -161,7 +161,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM")
def test_timeField_with_inputformat(self):
@ -178,7 +178,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:05 PM")
# Parse a time in a valid format, get a parsed result
@ -186,7 +186,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM")
def test_localized_timeField_with_inputformat(self):
@ -203,7 +203,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:05 PM")
# Parse a time in a valid format, get a parsed result
@ -211,7 +211,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM")
@ -228,7 +228,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid, but non-default format, get a parsed result
@ -236,7 +236,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
def test_localized_timeField(self):
@ -251,7 +251,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid format, get a parsed result
@ -259,7 +259,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
def test_timeField_with_inputformat(self):
@ -274,7 +274,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid format, get a parsed result
@ -282,7 +282,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
def test_localized_timeField_with_inputformat(self):
@ -297,7 +297,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:05")
# Parse a time in a valid format, get a parsed result
@ -305,7 +305,7 @@ class SimpleTimeFormatTests(SimpleTestCase):
self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "13:30:00")
@ -332,7 +332,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010')
# Parse a date in a valid, but non-default format, get a parsed result
@ -340,7 +340,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_localized_dateField(self):
@ -355,7 +355,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010')
# Parse a date in a valid format, get a parsed result
@ -363,7 +363,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_dateField_with_inputformat(self):
@ -382,7 +382,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
# Parse a date in a valid format, get a parsed result
@ -390,7 +390,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_localized_dateField_with_inputformat(self):
@ -409,7 +409,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
# Parse a date in a valid format, get a parsed result
@ -417,7 +417,7 @@ class LocalizedDateTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
@ -435,7 +435,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010')
# Parse a date in a valid, but non-default format, get a parsed result
@ -443,7 +443,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_localized_dateField(self):
@ -458,7 +458,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010')
# Parse a date in a valid format, get a parsed result
@ -466,7 +466,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_dateField_with_inputformat(self):
@ -483,7 +483,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
# Parse a date in a valid format, get a parsed result
@ -491,7 +491,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
def test_localized_dateField_with_inputformat(self):
@ -508,7 +508,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
# Parse a date in a valid format, get a parsed result
@ -516,7 +516,7 @@ class CustomDateInputFormatsTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010")
@ -533,7 +533,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
# Parse a date in a valid, but non-default format, get a parsed result
@ -541,7 +541,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
def test_localized_dateField(self):
@ -556,7 +556,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
# Parse a date in a valid format, get a parsed result
@ -564,7 +564,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
def test_dateField_with_inputformat(self):
@ -579,7 +579,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
# Parse a date in a valid format, get a parsed result
@ -587,7 +587,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
def test_localized_dateField_with_inputformat(self):
@ -602,7 +602,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
# Parse a date in a valid format, get a parsed result
@ -610,7 +610,7 @@ class SimpleDateFormatTests(SimpleTestCase):
self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21")
@ -637,7 +637,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010 13:30:05')
# Parse a date in a valid, but non-default format, get a parsed result
@ -645,7 +645,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:00")
def test_localized_dateTimeField(self):
@ -660,7 +660,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '21.12.2010 13:30:05')
# Parse a date in a valid format, get a parsed result
@ -668,7 +668,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:00")
def test_dateTimeField_with_inputformat(self):
@ -687,7 +687,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:05")
# Parse a date in a valid format, get a parsed result
@ -695,7 +695,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:00")
def test_localized_dateTimeField_with_inputformat(self):
@ -714,7 +714,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:05")
# Parse a date in a valid format, get a parsed result
@ -722,7 +722,7 @@ class LocalizedDateTimeTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "21.12.2010 13:30:00")
@ -740,7 +740,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '01:30:05 PM 21/12/2010')
# Parse a date in a valid, but non-default format, get a parsed result
@ -748,7 +748,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM 21/12/2010")
def test_localized_dateTimeField(self):
@ -763,7 +763,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, '01:30:05 PM 21/12/2010')
# Parse a date in a valid format, get a parsed result
@ -771,7 +771,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM 21/12/2010")
def test_dateTimeField_with_inputformat(self):
@ -788,7 +788,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:05 PM 21/12/2010")
# Parse a date in a valid format, get a parsed result
@ -796,7 +796,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM 21/12/2010")
def test_localized_dateTimeField_with_inputformat(self):
@ -813,7 +813,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:05 PM 21/12/2010")
# Parse a date in a valid format, get a parsed result
@ -821,7 +821,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "01:30:00 PM 21/12/2010")
@ -838,7 +838,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
# Parse a date in a valid, but non-default format, get a parsed result
@ -846,7 +846,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
def test_localized_dateTimeField(self):
@ -861,7 +861,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
# Parse a date in a valid format, get a parsed result
@ -869,7 +869,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
def test_dateTimeField_with_inputformat(self):
@ -884,7 +884,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
# Parse a date in a valid format, get a parsed result
@ -892,7 +892,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:00")
def test_localized_dateTimeField_with_inputformat(self):
@ -907,7 +907,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:05")
# Parse a date in a valid format, get a parsed result
@ -915,5 +915,5 @@ class SimpleDateTimeFormatTests(SimpleTestCase):
self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
text = f.widget.format_value(result)
self.assertEqual(text, "2010-12-21 13:30:00")