Error:
Reverse for ‘charges_report’ with arguments ‘(u’rtcl’, datetime.date(2012, 1, 3), datetime.date(2012, 1, 4), u”)’ and keyword arguments ‘{}’ not found.
in my urls.py
url(r'^charges_report/(?P<company_name>[\s\w\d-]+)/(?P<start_date>[\s\w\d-]+) /(?P<close_date>[\s\w\d-]+)/(?P<batch_no>[\s\w\d-]+)/$',
'admin.reports.views.charges_report',
name='charges_report'),
and in my form views on POST
When user submits form the error is occurring. I mean on request.POST, Here is the code for form submit
if request.POST:
company_form = CompanyForm(request.POST, request=request)
if company_form.is_valid():
company_name = company_form.cleaned_data['company_name']
start_date = company_form.cleaned_data['start_date']
close_date = company_form.cleaned_data['close_date']
batch_no = company_form.cleaned_data['batch_no']
#if 'immigration_charges' in request.POST:
return HttpResponseRedirect(reverse('charges_report',args=[company_name, start_date, close_date, batch_no]))
in views
def charges_report(request, company_name, start_date, close_date, batch_no=None,):
Your URL is taking keyword arguments, but you are passing positional arguments in
reverse.Try:
You also need to format your dates to match the regular expression in your URL pattern. Right now you are passing the literal string
datetime.date(2012, 1, 3)as thestart_date.Change
start_date(andclose_date) to something that matches your regular expression, something like this: