Ok got this fixed. The problem comes if you enter invalid data. return
dateformat.format(value, self.format) would throw an exception and the
form would render to ""
class DateFormattedTextInput(FormattedTextInput):
"Renders formatted date."
def __init__(self, format=None, attrs=None):
super(DateFormattedTextInput, self).__init__(attrs)
self.format = format or settings.DATE_FORMAT
def format_value(self, value):
if value:
try: #here was the problem
return dateformat.format(value, self.format)
except:
return value
else:
return value
Solves this. If the value can not be formated the original one is
returned.
BTW: the problem only occured after calling form.isvalid().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---