1 | #!/usr/bin/env python3
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 |
|
---|
4 | from django.shortcuts import render_to_response
|
---|
5 | from django.views.decorators.csrf import csrf_protect
|
---|
6 | from django.template import RequestContext
|
---|
7 |
|
---|
8 | from foo.forms import TestForm
|
---|
9 |
|
---|
10 |
|
---|
11 | def testrequest(request):
|
---|
12 | items = sorted(request.META.items())
|
---|
13 | return render_to_response('testrequest.html', {'items': items, 'kekse': request.COOKIES.items(), 'encoding': request.encoding})
|
---|
14 |
|
---|
15 | @csrf_protect
|
---|
16 | def formtest(request):
|
---|
17 | form = TestForm(request.POST)
|
---|
18 | form.is_valid()
|
---|
19 | try:
|
---|
20 | Text = form.cleaned_data['Text']
|
---|
21 | except:
|
---|
22 | Text = 'FAIL'
|
---|
23 | return render_to_response('formtest.html', {'form': form, 'Text': Text}, context_instance=RequestContext(request))
|
---|