Hey,
I am having a view called home with some form and a submit button. The data put into the form is going to be used to calculate some math. After submitting I want to show the user the calculated result on a new view. Therefore i figured redirecting would be the best way to do that. I am redirecting as follows:
def home(request):
if request.method == 'POST':
form = BoxSize(request.POST)
if form.is_valid():
data = form.cleaned_data
return redirect("result", data=data)
the result view :
def result(request, data):
return render(request,'mysite/result.html', {'data' : data)
urls:
path('result/', result, name="result")
Now i get a error: NoReverseMatch
So i guess, there is a problem with the urls definition as it is missing the ‘data’ parameter in the def results(). Am i on the right track - in the sense how it is supposed to be done in django? I had it working if i render directly in the def home() instead of redirecting. But it felt that it would be cleaner if it is redirected to the actual view. Thanks