Fixed #5851 -- Allowed specifying different HTML attrs for SplitDateTimeWidget subwidgets.

Thanks Tim Graham and Nick Pope for review.
This commit is contained in:
Mariusz Felisiak 2017-01-13 12:48:30 +01:00 committed by Tim Graham
parent 3a148f958d
commit 0034e9af18
5 changed files with 52 additions and 9 deletions

View file

@ -37,6 +37,18 @@ class SplitDateTimeWidgetTest(WidgetTest):
'<input type="text" class="pretty" value="07:30:00" name="date_1" />'
))
def test_constructor_different_attrs(self):
html = (
'<input type="text" class="foo" value="2006-01-10" name="date_0" />'
'<input type="text" class="bar" value="07:30:00" name="date_1" />'
)
widget = SplitDateTimeWidget(date_attrs={'class': 'foo'}, time_attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitDateTimeWidget(date_attrs={'class': 'foo'}, attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitDateTimeWidget(time_attrs={'class': 'bar'}, attrs={'class': 'foo'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
def test_formatting(self):
"""
Use 'date_format' and 'time_format' to change the way a value is