I'm attempting to take 4-5 fields from a large django form and display them on the thanks page.
I want to disply the values with a good degree of control, as i'll be building an iFrame with parameterd querystrings based on the form inputs.
Currently I have:
forms.py ----
-*- encoding: utf-8 -*-
from django import forms
from django.forms import extras, ModelForm
from django.utils.safestring import mark_safe
from siteapp.compare.models import Compare
HOWMUCH_CHOICES = (
('', '--------------------------'),
('20000', '20,000'),
('30000', '30,000'),
...
('2000000', '2,000,000'),
)
HOWLONG_CHOICES = (
('', '--------------------------'),
('1', '1 Year'),
...
('39', '39 Years'),
('40', '40 Years'),
)
...etc.
class ComparisonForm(forms.Form):
js = mark_safe(u"document.compareForm.how_much.selectedindex = 4;")
how_much = forms.ChoiceField(choices=HOWMUCH_CHOICES,
widget=forms.Select(attrs={'onMouseOver':'setDefaults()','class':'required validate-selection','title':'Select value of cover required','onLoad': js}))
how_long = forms.ChoiceField(choices=HOWLONG_CHOICES,
widget=forms.Select(attrs={'class':'required validate-selection','title':'Select length of cover required'}))
who_for = forms.ChoiceField(choices=WHOFOR_CHOICES,
widget=forms.Select(attrs={'class':'required validate-selection','title':'Select whether you require cover for a partner also'}))
...
class Meta:
model = Compare
models.py -----
class Compare(models.Model):
how_much = models.CharField(max_length=28,choices=HOWMUCH_CHOICES#,default='100000'
)
how_long = models.CharField(max_length=28,choices=HOWLONG_CHOICES)
who_for = models.CharField(max_length=28,choices=WHOFOR_CHOICES)
...
partner_date_of_birth = models.DateField(blank=True)
def __unicode__(self):
return self.name
views.py----
def qc_comparison(request):
return render_to_response('compare/compare.html', locals(), context_instance=RequestContext(request))
urls.py----
(r'^compare/thanks/$', 'django.views.generic.simple.direct_to_template', {'template': 'compare/thanks.html'}),
I'm trying to dig out the best way to do this fromt he documentation, but it's not clear how to pass the variables correctly to a thanks page. Any help appreciated!