Reputation: 13314
In the form, everything is working, the less HttpResponseRedirect
I'm trying to redirect the contents of the form to the rateio.html
. However, this showing the error:
NoReverseMatch at /proposal/
Reverse for 'rateio/' with arguments '()' and keyword arguments '{'table': .......
What I am finding strange is that I'm pointing to the rateio
with reverse('rateio/', ...
only that Django is looking for /proposal/
Someone could tell me what I'm doing wrong? Thank you for attention.
views.py
def proposal(request):
if request.method == 'POST':
form = Proposal(request.POST)
if form.is_valid():
validate, content = table_split(request.POST)
if validate==True:
table, priority, total_sum = valido(content)
json_priority = simplejson.dumps(priority)
json_total_sum = simplejson.dumps(total_sum)
return HttpResponseRedirect(reverse('rateio/', kwargs={'table':table, 'priority' : json_priority, 'total_sum' : json_total_sum}))
if validate==False:
return render_to_response('proposal.html', {'form' : form, 'not_validate' : 'Incorrectly filled in proposal fill again'}, context_instance=RequestContext(request))
else:
return render_to_response('proposal.html', {'form' : form, 'not_validate' : 'Incorrectly filled in proposal fill again'}, context_instance=RequestContext(request))
else:
form = Proposal()
return render_to_response('proposal.html', {'form' : form}, context_instance=RequestContext(request))
def rateio(request,data):
return render_to_response('rateio.html', {'table':data[table], 'priority' : data[priority], 'total_sum' : data[total_sum]}, context_instance=RequestContext(request))
urls.py
url(r'^rateio/$', 'mge.core.views.rateio'),
url(r'^proposal/$', 'mge.core.views.proposal'),
proposal.html
<form action="" method="post">
{% csrf_token %}
.....
<input type="submit" value="Send">
</form>
Upvotes: 0
Views: 897
Reputation: 600059
You have two errors.
Firstly, the first parameter to reverse
is the view name, not the URL. So it should be 'mge.core.views.rateio' as in urls.py. Or even better, give the pattern an explicit name - name="ratio"
and use that.
Secondly, you have three kwargs you're trying to pass, but the ratio URL does not accept any parameters. What are you hoping to do with those values? Two of them are JSON docs, you wouldn't want to pass those in the URL.
Upvotes: 1