Django AuthenticationForm не работает выдает ошибку имя 'UsernameField' не определено

Это мой код

class LoginForm(AuthenticationForm):
    username = UsernameField(label='username', widget=forms.TextInput(attrs={'autofocus':True,'class':'form-control'}))
    password = forms.CharField(label =_("Password"), strip=False, widget=forms.PasswordInput(attrs={'autocomplete':'current-password', 'class':'form-control'}))

когда я запускаю сервер, возникает эта ошибка (NameError: name 'UsernameField' is not defined)

    class LoginForm(AuthenticationForm):
  File "E:\07_Django_All\03_ecommerce_site(Project)\Ecommerce_site\app\forms.py", line 19, in LoginForm
    username = UsernameField(label='username', widget=forms.TextInput(attrs={'autofocus':True,'class':'form-control'}))
NameError: name 'UsernameField' is not defined

Вы должны импортировать UsernameField из django.contrib.auth.forms

from django.contrib.auth.forms import AuthenticationForm, UsernameField
Вернуться на верх