I am trying to come up with a form that lets the user select a date range to generate a web query in Django. I am having errors getting the date to filter with in my view, I am unable to strip the date.
Here is my forms.py
class ReportFiltersForm(forms.Form):
start_date = forms.DateField(input_formats='%Y,%m,%d',widget=SelectDateWidget())
end_date = forms.DateField(input_formats='%Y,%m,%d',widget=SelectDateWidget())
And my view
if request.method == 'POST':
form = ReportFiltersForm(request.POST)
sdy = request.POST['start_date_year']
sdm = request.POST['start_date_month']
sdd = request.POST['start_date_day']
edy = request.POST['end_date_year']
edm = request.POST['end_date_month']
edd = request.POST['end_date_day']
start_date= datetime.date(sdy, sdm, sdd)
end_date= datetime.date(edy, edm,edd)
Traceback
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 651, in __call__
return self.application(environ, start_response)
File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 154, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/projects/acms/cms/views.py", line 470, in eventreports
start_date= datetime.date(sdy, sdm, sdd)
TypeError: an integer is required