Form Is Not Validating Because Of Date Field Is Not A Valid Format
Form is not validating because of date field is not a valid format can any one help me. settings.py USE_I18N = True USE_L10N = True USE_TZ = True API = 'Apache-HttpClient' ACCE
Solution 1:
When you look at a query dict (e.g. request.POST
), you will see lists, because HTML forms can submit multiple values for the same key.
However, when you construct the data dictionary manually, you should use strings instead of lists.
a = {u'From': 'Bangalore', u'userid': '50', u'choice':'(4,)', u'to':'Goa', u'from_date':'2016-10-20', u'to_date':'2016-10-23'}
abc = SaveTripForm(a)
Solution 2:
Actually the Problem with the request.POST
data.
Form is not validating because of post data value are in LIST.
For this issue we can achieve like this
abc = SaveTripForm(a.dict())
Shell
python manage.py shell
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>a = {u'From':[u'Bangalore'], u'userid':[u'50'], u'choice':[u'(4,)'], u'to':[u'Goa'], u'from_date':[u'2016-10-20'], u'to_date':[u'2016-10-23']}>>>from uprofile.forms import SaveTripForm>>>abc = SaveTripForm(a.dict())>>>abc.is_valid()
True
>>>abc.errors
{}
>>>
Post a Comment for "Form Is Not Validating Because Of Date Field Is Not A Valid Format"