Hi,

I've written my own view to create / edit model instances my project,
and part of what I wanted to do was to accept dates only in the format
dd-mm-yyyy (%d-%m-%Y).

I searched around a bit and came accross this post:
http://groups.google.com/group/django-users/browse_thread/thread/9f84d1b920e54dd2/bbc7857c120c8ecb.
Creating my own model field class seemed pretty extreme, but I quickly
worked out that I can do this much more simply by adding a line to my
ModelForm:

class EventForm(ModelForm):
        start_date = forms.DateField(input_formats=['%d-%m-%Y'])

This changes the behaviour, and works fine for validating dates
written in non- US format.


My problem is that when I create an EventForm from a model instance
(for my 'edit' functionality) the date fields (rendered as html text
inputs) are populated in the standard %Y-%m-%d format. Submitting the
form as populated is therefore invalid, so I have to manually play
with the dates each time I edit an event.

How would I go about changing this behaviour? I understand that patch
1.1 might address this (by typing date format to locale), but I would
like to see if I can knock up a temporary solution.

Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to