AttributeError at /register/
type object 'User' has no attribute 'USERNAME_FIELD'
Делаю сайт с регистрацией пользователей и получил данную ошибку при открытии страницы регистрации.
Model:
class User(models.Model):
username = models.CharField(max_length=30, unique=True)
email = models.EmailField(blank=True)
password = models.CharField(max_length=30)
password1 = models.CharField(max_length=30)
Form:
class RegisterUserForm(UserCreationForm):
username = forms.CharField(label='Логин', widget=forms.TextInput(attrs={'class': 'form-input'}))
email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={'class': 'form-input'}))
password1 = forms.CharField(label='Пароль', widget=forms.PasswordInput(attrs={'class': 'form-input'}))
password2 = forms.CharField(label='Повтор пароля', widget=forms.PasswordInput(attrs={'class': 'form-input'}))
class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')
View:
class RegisterUser(CreateView):
form_class = RegisterUserForm
template_name = 'main/reg.html'
success_url = reverse_lazy('login')