#3672: newforms: DateField doesn't handle date output formats
----------------------------------------+-----------------------------------
Reporter: [email protected] | Owner: ajs
Status: new | Milestone: post-1.0
Component: Forms | Version: SVN
Resolution: | Keywords: DateField l10n
localization format input output
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
----------------------------------------+-----------------------------------
Changes (by [email protected]):
* milestone: => post-1.0
Comment:
Hello
i think
def format_value(self, value):
if isinstance(value, datetime.date) or isinstance(value,
datetime.datetime):
return value.strftime(self.format)
else:
return value
needs to be changed to:
def format_value(self, value):
if isinstance(value, datetime.date) or isinstance(value,
datetime.datetime):
try:
return value.strftime(self.format)
except:
return value
else:
return value
Otherwise the value.strftime(self.format) would crash the form (form
render returns "") if the field-value does not validate on calling
form.is_valid()
If my approach is wrong please let me know. I'm very new to django/python
:)
--
Ticket URL: <http://code.djangoproject.com/ticket/3672#comment:17>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---