view from other testclass import Test from django http import HttpResp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#view
from other.testclass import Test
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
def test(request):
if request.method == 'POST':
form = Test(request.POST)
if form.is_valid():
return HttpResponseRedirect('/profile/')
else:
form = Test()
return render_to_response('test.html',{'form':form})
#form class
from django import newforms as forms
class Test(forms.Form):
user = forms.CharField(max_length=100)
#template
<form action="" method="post">
<table>
{{ form }}
</table>
<input type="submit" value="submit" />
</form>