1
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm, UserChangeForm
2
from django import forms
3
from authapp.models import AuthUser
6
class AuthUserLoginForm(AuthenticationForm):
10
fields = ('username', 'password')
12
def __init__(self, *args, **kwargs):
13
super().__init__(*args, **kwargs)
14
for field_name, field in self.fields.items():
15
field.widget.attrs['class'] = 'form-control'
19
class AuthUserRegisterForm(UserCreationForm):
23
fields = ('username', 'nickname', 'birthdate', 'email', 'avatar')
25
def __init__(self, *args, **kwargs):
26
super().__init__(*args, **kwargs)
27
for field_name, field in self.fields.items():
28
field.widget.attrs['class'] = 'form-control'
32
class AuthUserEditForm(UserChangeForm):
35
fields = ('username', 'nickname', 'birthdate', 'email', 'avatar', 'password')
37
def __init__(self, *args, **kwargs):
38
super().__init__(*args, **kwargs)
39
for field_name, field in self.fields.items():
40
field.widget.attrs['class'] = 'form-control'