View difference between Paste ID: NBWHfkG7 and M5HWWYQK
SHOW: | | - or go back to the newest paste.
1
def contact(request):
2
    if request.method == 'POST': # If the form has been submitted...
3
        # ContactForm was defined in the previous section
4
        form = ContactForm(request.POST) # A form bound to the POST data
5
        if form.is_valid(): # All validation rules pass
6
            # Process the data in form.cleaned_data
7
            # ...
8
            return HttpResponseRedirect('/thanks/') # Redirect after POST
9
    else:
10
        form = ContactForm() # An unbound form
11
12
    return render(request, 'contact.html', {
13
        'form': form,
14
    })