Ticket #19101: views.py

File views.py, 728 bytes (added by kristall, 2 years ago)

The used view

Line 
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4from django.shortcuts import render_to_response
5from django.views.decorators.csrf import csrf_protect
6from django.template import RequestContext
7
8from foo.forms import TestForm
9
10
11def 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   
16def 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))
Back to Top