On Sep 30, 2:19 pm, Gerard Petersen <[EMAIL PROTECTED]> wrote: > That did the trick. It does, however, leave me with a previous problem. When > I edit the object via a form (in my app) it displays the field value like > this "2008-09-30". And due to field validation the form widget only accepts > this format: "30-09-2008". > > Any clue on how a datefield contents then would be correctly presented in a > form when the format deviates from how it's stored in a mySQL database?
How it's stored in a MySQL database is completely irrelevant to you, as Django abstracts that away. The form widget receives a Python datetime.date object, for which the default string representation is the form "2008-09-30". If you use a stock forms.DateField and don't mess with the validation, it will work just fine (and accept a variety of date formats from user input[1]). If you override the validation to require a different format, you could use a custom widget that overrides the render() method to coerce the date object to the string representation you prefer. This should be easier to customize; for more info see ticket 3672 [2] [1] http://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.DateTimeField.input_formats [2] http://code.djangoproject.com/ticket/3672 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---