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..

3 Answers

0
dzen On Best Solutions

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 ?

1
dzen On

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

0
meshantz On

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.