我正试图提出一个表格,让用户选择一个日期范围,在詹戈产生一个网络查询。 我认为,我错了过滤日期,我无法缩短日期。
我的<代码>form.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())
我的看法
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)
追查
追查 (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