In my Django webapp, I have a user submit data to Form1.html. The data is passed onto Form2.html where they submit more data. After they submit Form2 they are taken to Done.html.
Form1 >> Form2 >> Done
The problem is I need the data from Form1 in From2 and in the Done view. Getting the data from Form1 to the Form2 view is no problem, just grab the values from request.POST['value']
. In Form2 view, how do I pass on the Form1-data to the Done view? I thought that I could just modify the POST object in Form2 like below and pass the request object on:
def form2(request):
form1string = request.POST['inputbox1']
request.POST = request.POST.copy() # make the POST QueryDict mutable
request.POST.setdefault('data1', form1string)
t = loader.get_template('done.html')
c = RequestContext( request, { # pass on old request so new POST data is passed on
'blah': some_var,
})
c.update(csrf(request)) # add the csrf_token to the Context dictionary
return HttpResponse(t.render(c))
I'm kind of hesitant to use django.sessions
as not everyone has cookies enabled.
Thanks in advance for the help!