tags:

views:

63

answers:

3

Here's my function:

def check_form(request):
    if request.method == 'POST':
        form = UsersForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            try:
                newUser = form.save()
                return HttpResponseRedirect('/testproject/summery/)
            except Exception, ex:
                # sys.stderr.write('Value error: %s\n' % str(ex)
                return HttpResponse("Error %s" % str(ex))
        else:
            return render_to_response('index.html', {'form': form}, context_instance=RequestContext(request))
    else:
        form = CiviguardUsersForm()
    return render_to_response('index.html',context_instance=RequestContext(request))

I want to pass each and every field in to a page call summery and display all the fields when user submits the form, so then users can view it before confirming the registration.

Thanks..

+1  A: 

You may want to use the sessions, as described in http://docs.djangoproject.com/en/dev/topics/http/sessions/ ?

dzen
Is there any other way of doing this without using sessions ?
MMRUser
A: 

You could take a look at the Form Wizard which is included in the formtools contrib app. It's handy for creating multi-page forms, while keeping all of the data around.

meshantz
A: 

You could build a dictionnary, with all your form fields, and use "render_to_response" :

newUser = form.save()
data = {}
for field in dir(newUser):
    if isinstance(getattr(newUser, field), Field):
        data[field] = getattr(newUser, field)
return render_to_response('summary.html', data, context_instance=RequestContext(request))

and use the variables in your template ?

dzen
But in this case the browser wouldn't show "/testproject/summary/" in its address line.
MartinStettner