Authentication Form Customize, Doubles Field.

The Goal is To Customize Form, Then Pass it to LoginView.

I am using AuthenticationForm after Customizing it, but i see it repeats extra one input,
I guess it is for username, i need only two inputs, E-Mail and Password.
any advice.

class AccountSignInForm(AuthenticationForm):
    email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'E-Mail..'}), label='E-Mail')
    password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password..'}), label='Password')

    class Meta:
        model = Account
        fields = ['email', 'password']


app_name = 'accounts'

urlpatterns = [
    path('sign-in', views.AccountLoginView.as_view(), name='login'),


class AccountLoginView(LoginView):
    template_name = 'accounts/login.html'
    form_class = AccountSignInForm
    success_url = 'HomePageView'


<h1>Login Form</h1>
<form method="POST">
	{% csrf_token %}
    {% for field in form %}
        <div>{{ field.label }}</div>
        <div>{{ field }}</div>
    {% endfor %}
    <input type="submit" value="Login" />


Hello @AhmdMWddh
As you say, the extra field is for the username field.
You can see it here: django/ at main · django/django · GitHub
What you could do if you don’t want the “username” field being showed inside the form is to override it to a hidden input.
Just remember that this won’t work if you didn’t customize also your authentication module. What I mean is that Django, by default, uses the username and password fields to login. The email field is there only for information purposes.
If you want to use the email field as “username” field, at least for authentication, you need to create a model inheriting from “AbstractUser” and set the USERNAME_FIELD property to email. You could also write your own authentication module, but option needs more work involved.
You can see more information about the first option here: Add custom field to Django Admin authentication form - Stack Overflow

Great Thanks Urimeba,
Yes, I have this Custom User with USERNAME_FIELD = email thanks for information pal.

class UserManager(BaseUserManager):
    def create_user(self, email, first_name, last_name, password=None):
        if not email:
            raise ValueError('E-Mail is Required, Please Provide Your E-Mail.')
        if not first_name:
            raise ValueError('E-Mail is Required, Please Provide Your First Name.')
        if not last_name:
            raise ValueError('E-Mail is Required, Please Provide Your Last Name.')
        user = self.model(
        user.is_staff = True
        return user

    def create_superuser(self, email, first_name, last_name, password=None):
        user = self.create_user(
        user.is_superuser = True
        return user

class User(AbstractBaseUser):
    email = models.EmailField(verbose_name='email', max_length=255, unique=True)
    first_name = models.CharField(verbose_name='First Name', max_length=255)
    last_name = models.CharField(verbose_name='Last Name', max_length=255)
    date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
    last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=False)
    is_superuser = models.BooleanField(default=False)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['first_name', 'last_name']

    objects = UserManager()

    def full_name(self):
        return f'{self.first_name} {self.last_name}'

    def __str__(self):
        return f'{} - {self.full_name}'

    def has_perm(self, perm, obj=None):
        return self.is_staff

    def has_module_perms(self, app_label):
        return True