@@ -9,43 +9,24 @@ class UserRegisterForm(UserCreationForm):
99 label = _ ("Имя" ),
1010 max_length = 30 ,
1111 required = True ,
12- widget = forms .TextInput (attrs = {
13- 'placeholder' : 'Имя' ,
14- # 'name': 'first_name' # обычно не обязательно добавлять вручную
15- }),
12+ widget = forms .TextInput (attrs = {'placeholder' : 'Имя' }),
1613 )
1714 last_name = forms .CharField (
1815 label = _ ("Фамилия" ),
1916 max_length = 30 ,
2017 required = True ,
21- widget = forms .TextInput (attrs = {
22- 'placeholder' : 'Фамилия' ,
23- }),
24- )
25- username = forms .CharField (
26- label = _ ("Имя пользователя" ),
27- max_length = 150 ,
28- required = True ,
29- widget = forms .TextInput (attrs = {
30- 'placeholder' : 'Имя пользователя' ,
31- }),
32- )
33- password1 = forms .CharField (
34- label = _ ("Пароль" ),
35- strip = False ,
36- required = True ,
37- widget = forms .PasswordInput (attrs = {
38- 'placeholder' : 'Пароль' ,
39- }),
40- )
41- password2 = forms .CharField (
42- label = _ ("Подтверждение пароля" ),
43- strip = False ,
44- required = True ,
45- widget = forms .PasswordInput (attrs = {
46- 'placeholder' : 'Подтверждение пароля' ,
47- }),
18+ widget = forms .TextInput (attrs = {'placeholder' : 'Фамилия' }),
4819 )
20+ # остальные поля ...
21+
22+ def save (self , commit = True ):
23+ user = super ().save (commit = False )
24+ user .first_name = self .cleaned_data ['first_name' ]
25+ user .last_name = self .cleaned_data ['last_name' ]
26+ if commit :
27+ user .save ()
28+ return user
29+
4930
5031
5132class UserUpdateForm (forms .ModelForm ):
0 commit comments