I'm trying to create a simple Django multi-page form using FormWizard. What the form should do is the following:
- Let the visitor enter first and lastname in a form.
- Continue to next page where entered previously firstname and lastname will be displayed, there will also be a field on this page that let's the visitor enter a message.
- The visistor will be taken to the Django done.html page where all information will be stored and displayed.
In step 2, I'm having trouble figuring out how to display the information that the visitor entered in step 1. I'm posting the code for the forms and the two templates used for step 1 and 2 below:
forms.py
from django import forms
from django.shortcuts import render_to_response
from django.contrib.formtools.wizard import FormWizard
class ContactWizard(FormWizard):
def done(self, request, form_list):
return render_to_response('done.html', {
'form_data': [form.cleaned_data for form in form_list],
})
def get_template(self, step):
return 'buydomain/templates/reg%s.html' % step
class Form1(forms.Form):
firstName = forms.CharField()
lastName = forms.CharField()
class Form2(forms.Form):
message = forms.CharField(widget=forms.Textarea)
template for step 1:
{% block content %}
<p>Step {{ step }} of {{ step_count }}</p>
<form action="." method="post">
<table>
{{ form }}
</table>
<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
{{ previous_fields|safe }}
<input type="submit">
</form>
{% endblock %}
template for step 2:
{% block content %}
<p>Step {{ step }} of {{ step_count }}</p>
{% comment %}
Show values entered into Form1 here !
{% endcomment %}
<form action="." method="post">
<table>
{{ form }}
</table>
<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
{{ previous_fields|safe }}
<input type="submit">
</form>
{% endblock %}
I apologize if I'm somewhat unclear about what I want to achieve, and I'm hopefully waiting for someone to supply a solution. Thanks in advance.