django/forms/widgets.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index fe7c06f..64317e5 100644
a
|
b
|
class Input(Widget):
|
248 | 248 | """ |
249 | 249 | input_type = None # Subclasses must define this. |
250 | 250 | |
| 251 | dt_formats = { |
| 252 | datetime.date: 'DATE_INPUT_FORMATS', |
| 253 | datetime.datetime: 'DATETIME_INPUT_FORMATS', |
| 254 | datetime.time: 'TIME_INPUT_FORMATS', |
| 255 | } |
| 256 | |
251 | 257 | def _format_value(self, value): |
252 | 258 | if self.is_localized: |
253 | 259 | return formats.localize_input(value) |
| 260 | elif hasattr(value, 'strftime'): |
| 261 | format = formats.get_format(self.dt_formats[type(value)])[0] |
| 262 | if type(value) is datetime.date: |
| 263 | value = datetime_safe.new_date(value) |
| 264 | if type(value) is datetime.datetime: |
| 265 | value = datetime_safe.new_datetime(value) |
| 266 | return value.strftime(format) |
254 | 267 | return value |
255 | 268 | |
256 | 269 | def render(self, name, value, attrs=None): |