2👍
✅
You should be using the same view (and the same url) to render the form as you use to process the form (have a look at this example in the django docs). On successful processing of your form use a reverse to redirect to the page you need.
Something like –
def vote_form(request):
if request.method == 'POST': # If the form has been submitted...
form = VoteForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect(reverse('my_view_name',
kwargs={'objectid':x, 'score': y}))
else: # We're just rendering the html form
form = VoteForm() # An unbound form
return render(request, 'vote.html', {
'form': form,
})
Source:stackexchange.com