﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12038	http://docs.djangoproject.com/en/dev/topics/forms/ contact example	ilkka	nobody	"
== The example ==

{{{
def contact(request):
    if request.method == 'POST': # If the form has been submitted...
        form = ContactForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            # ...
            return HttpResponseRedirect('/thanks/') # Redirect after POST
    else:
        form = ContactForm() # An unbound form

    return render_to_response('contact.html', {
        'form': form,
    })

}}}

== Is tad more clear in this form ==

{{{
def contact(request):
    if request.method == 'POST': # If the form has been submitted...
        form = ContactForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            # ...
            return HttpResponseRedirect('/thanks/') # Redirect after POST
        else: #invalid data, the bound form instance is passed on to the template.
            return render_to_response('contact.html', {'form': form}) 
    else:
        form = ContactForm() # An unbound form

   

}}}

"		closed	Documentation	1.1		invalid	code example		Unreviewed	0	0	0	0	0	0
