class RegistrationForm forms Form username forms CharField min_length

 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
class RegistrationForm(forms.Form):
username = forms.CharField(min_length=2,max_length=32)
password = forms.CharField(min_length=2,max_length=32, widget=forms.PasswordInput)
repassword = forms.CharField(min_length=2,max_length=32, widget=forms.PasswordInput)
name = forms.CharField(max_length=64)
surname = forms.CharField(max_length=64)
born_year = forms.ChoiceField()
country = forms.CharField(max_length=16)
city = forms.CharField(max_length=30)
site = forms.URLField()
sex = forms.CharField(max_length=16)
In [1]: from forms.models import RegistrationForm
In [2]: TEMP = {'username':'aliens',
...: 'password':'pass',
...: 'repassword':'pass',
...: 'name':'name',
...: 'surname':'',
...: 'born_year':'',
...: 'country':'',
...: 'city':'',
...: 'site':'www.ya.ru',
...: 'sex':'male'}
In [3]: form = RegistrationForm(TEMP)
In [4]: form.is_valid()
Out[4]: False