views:

208

answers:

1

My locale dateformat is dd/mm/yyyy and Django is requering AAAA-MM-DD

when the user inputs 04/11/2009 Django raises:

_('Enter a valid date in YYYY-MM-DD format.'))

Im using simple html input field type="text", Not forms.DateField

Thanks :)

+3  A: 

I'm assuming you are using a forms.DateField. If so, you need to supply a input_formats argument like so:

class MyForm(forms.Form):
    start_date = forms.DateField(input_formats=['%d/%m/%Y'])

input_formats just takes a list of the formats you want to accept.

See http://docs.djangoproject.com/en/dev/ref/forms/fields/#datefield for more information.

richleland
rich, I did your suggest and still the same problem: ValidationErrorException Value: Introduzca una fecha válida en formato AAAA-MM-DD.
panchicore
can you paste the full code? both from the forms.py and views.py?
richleland
thanks. see the code here: http://pastebin.com/m3cc103e7
panchicore
there are a few things i noticed in your code that would have to be addressed before trying to pinpoint the ValidationError. most notably is_valid should be is_valid(). i've made mods to the pasted code (http://pastebin.com/d29e92c68) and highlighted important lines that i modified.
richleland
(pastebin.com/d29e92c68) Unknown post id, it may have expired or been deleted :( Did you put it to 1 day-expire?
panchicore