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