I've always solved this problem in javascript. Plus if you're using jquery it's a bit easier. Before you set the date picker just format the date:
$('input#id_date').val($('input#id_date').val().replace(/(\d+)-(\d+)- (\d+)/ig, '$3/$2/$1')).datepicker({showOn: 'focus', dateFormat: 'dd/mm/ yy'}); Hope that helps. I would also like to know if the output format can be changed from django. On Aug 3, 7: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. > > Alan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---