python - POST date values in django testCase -


i trying write test sign user. can't form validate because can't figure out how submit valid date form. here offending code:

class accountmanagementtest(testcase):     def test_signup(self):         response = self.client.post(reverse('register'), {             'first_name': 'gandalf',              'last_name': 'thegrey',              'email': 'gandalf@me.com',              'password1': 'sauronsucks',              'password2': 'sauronsucks',              'birthdate': datetime(1956, 1, 1),             'tos': true}) 

i can output response.content afterwards , error in form 'please enter valid date.' have not overridden clean method birthdate in form. here's declaration of date field form:

birthdate = forms.datefield(         widget=selectdatewidget(             years=range(this_year-90, this_year-12)[::-1]),             required=true,) 

how heck send valid date?

you need pass string representation of date matches 1 of default input_formats:

['%y-%m-%d',      # '2006-10-25' '%m/%d/%y',       # '10/25/2006' '%m/%d/%y']       # '10/25/06' 

in case be, example:

'birthdate': '1956-01-01' 

Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -