SHOW:
|
|
- or go back to the newest paste.
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, prefix='something-%s' % (some_id,), label_suffix=': ') |
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 | + | |
7 | - | # ... |
7 | + | form = ContactForm(prefix='something-%s' % (some_id,), label_suffix=': ') |
8 | - | return HttpResponseRedirect('/thanks/') # Redirect after POST |
8 | + | |
9 | return render(request, 'contact.html', { | |
10 | - | form = ContactForm() # An unbound form |
10 | + | |
11 | }) |