On Mon, Aug 3, 2009 at 2:08 PM, zayatzz <alan.kesselm...@gmail.com> wrote:

>
> Hello.
>
> I have this in my form (modelform) for birth_date field:
> birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> required=False ), which overrides this in model:
>
> birth_date = models.DateField(help_text="birth date",
> verbose_name="Birth date", blank=True, null=True, )
>
> I also have jquery datepicker on the page which sets date in the same
> format (%d/%m/%Y). But the form saves date in %Y-%m-%d format in
> database, which means that when user returns to reedit the data, the
> form wont validate and the user has to set the date again.
>
> Can anyone tell me what causes such behaviour and how to fix/change
> it? My database in mysql - no idea if this is relevant.
>

The format the existing date is displayed in is controlled by the field's
widget (it has nothing to do with how the data is stored in the database).
You want to specify a DateInput widget with a format that matches what the
field is expecting for input:

http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.DateInput

Note "new in development version" there means new in 1.1.  I think that was
in the 1.1 beta actually.

Karen

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to