I have a multi-page form in Django. That is to say I have multiple Django Form objects spread across five or so templates. What I would like to do is pass that form between the pages, then commit it to my model at the end of the string. My code snippet is as follows:
def firstFormStep(request):
if form.is_valid() :
for field in form :
request.session[str(field.name)] = form.cleaned_data[str(field.name)]
request.session.modified = True
request.session.save()
print ("Request: " + str(request.session.items()))
print ("Session: " + str(request.session.session_key))
return HttpResponseRedirect(reverse('core:nextFormStep'), request)
Before session.save() my session_key was None. Afterwards it is a number.
The first line of my next view is:
def nextFormStep(request):
print ("Session: " + str(request.session.session_key))
The session_key at this point is None. Somewhere in HttpResponseRedirect my session gets dropped. Why? How can I fix this?