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