0

I know there are a lot of threads alredy talking about this but there is none that remotely solved my problem. This is really weird because everything has been done how it's meant to be done.

Here is my forms.py:

from django import forms
from airspress import settings

class searchForm(forms.Form):
depDate1 = forms.DateField(required=False,  input_formats=settings.DATE_INPUT_FORMATS)
depDate2 = forms.DateField(required=False, input_formats=settings.DATE_INPUT_FORMATS)
cityDep = forms.CharField(required=False)
cityArr = forms.CharField(required=False)

And here is a simple test :

data = {'depDate1':'1-5-2015'}
boo = searchForm(data)
if boo.is_valid():
   pass
print boo.errors
#print: <ul class='errorlist'><li>depDate1<ul><li>Enter a valid date</li></ul></li></ul>

In short i have an "Enter a valid date" error, And i've tried absolutely everything, every kind of date format i can think of, it only works when i create an actual datetime.datetime object and assign to the field value. I've done lot of testing in actual rendered html form to no avail.

Hope I'm actually missing something and i'm not just doomed for the day...

Thank you very much !

konoufo
  • 427
  • 5
  • 15
  • [The documentation](https://docs.djangoproject.com/en/1.7/ref/settings/#date-format) has a note about date formats being ignored when a localization bool is set. Does that help at all? What's your `USE_L10N` setting? – Air Jan 08 '15 at 00:11
  • USE_L10N is set to TRUE. Do you think i should set it to False ? – konoufo Jan 08 '15 at 00:20
  • Not that familiar with django so I couldn't say, but it seems like it's worth a try. – Air Jan 08 '15 at 00:24
  • 1
    I don't know what happened. I didn't touch anything, i was just continuously banging my search button (on my local website) when it finally happened, no validation errors. 10 hours since i was tackling a problem which i don't even know what it was... And now this ! I don't know what to say but it's totally weird. – konoufo Jan 08 '15 at 00:26

1 Answers1

2

Well, i don't know what to say... Maybe Django had a "caching" problem or something like that. Because there don't seem to be a scripting problem which just happen to solve itself (unless there's a 3035 year robot software around). If anyone has this problem, follow the answers on other questions here, like this one :

django Enter a valid date. validation error

Thank you very much for you time @AirThomas .

Community
  • 1
  • 1
konoufo
  • 427
  • 5
  • 15