| 28 | |
| 29 | |
| 30 | def get_name(request): |
| 31 | # if this is a POST request we need to process the form data |
| 32 | if request.method == 'POST': |
| 33 | # create a form instance and populate it with data from the request: |
| 34 | form = NameForm(request.POST) |
| 35 | # check whether it's valid: |
| 36 | if form.is_valid(): |
| 37 | # process the data in form.cleaned_data as required |
| 38 | # ... |
| 39 | # redirect to a new URL: |
| 40 | return HttpResponseRedirect('/thanks/') |
| 41 | |
| 42 | # if a GET (or any other method) we'll create a blank form |
| 43 | else: |
| 44 | form = NameForm(data={'your_name': 'unknown name'}) |
| 45 | |
| 46 | return render(request, 'my_app/name.html', {'form': form}) |
| 47 | |
| 48 | |
| 49 | def inherits(request): |