title: How to Customize Login Form to be User's Email instead of User's Username
body: <p>I am following a tutorial for Login in Django and after finishing I found that the Login Form requires the Username and Password but I want to replace the username with the user's Email instead.</p>
  <p>Here is the views.py</p>
  <pre><code>@login_required
  def register(request):
      if request.method == 'POST':
          form = UserRegisterForm(request.POST)
          if form.is_valid():
              form.save()
              username = form.cleaned_data.get('username')
              messages.success(request, f'Your account has been created! You are now able to log in')
              return redirect('login')
      else:
          form = UserRegisterForm()
      return render(request, 'users/register.html', {'form': form})
   
   
  @login_required
  def profile(request):
      if request.method == 'POST':
          u_form = UserUpdateForm(request.POST, instance=request.user)
          p_form = ProfileUpdateForm(request.POST,
                                     request.FILES,
                                     instance=request.user.profile)
          if u_form.is_valid() and p_form.is_valid():
              u_form.save()
              p_form.save()
              messages.success(request, f'Your account has been updated!')
              return redirect('profile')
   
      else:
          u_form = UserUpdateForm(instance=request.user)
          p_form = ProfileUpdateForm(instance=request.user.profile)
   
      context = {
          'u_form': u_form,
          'p_form': p_form
      }
   
      return render(request, 'users/profile.html', context)
  </code></pre>
  <p>Here is the forms.py</p>
  <pre><code> 
  class UserRegisterForm(UserCreationForm):
      email = forms.EmailField()
   
      class Meta:
          model = User
          fields = ['username', 'email', 'password1', 'password2']
   
   
  class UserUpdateForm(forms.ModelForm):
      email = forms.EmailField()
   
      class Meta:
          model = User
          fields = ['username', 'email']
   
   
  class ProfileUpdateForm(forms.ModelForm):
      class Meta:
          model = Profile
          fields = ['image']
  </code></pre>
  <p>Here is the template</p>
  <pre><code>&lt;form class=&quot;login100-form validate-form&quot; method=&quot;POST&quot;&gt;
  &lt;span class=&quot;login100-form-title p-b-34&quot;&gt;
   Account Login
    &lt;/span&gt;
   &lt;fieldset class=&quot;input100 m-b-20&quot;&gt;
    {% csrf_token %}
    {{ form|crispy }}
       &lt;/fieldset&gt;
    &lt;div class=&quot;container-login100-form-btn&quot;&gt;
    &lt;button class=&quot;login100-form-btn&quot; type=&quot;submit&quot; style=&quot;width: 90%&quot;&gt;
         Sign in
     &lt;/button&gt;
   &lt;/div&gt;
   &lt;div class=&quot;w-full text-center p-t-27 p-b-100&quot;&gt;
    &lt;a class=&quot;txt2&quot; href=&quot;{% url 'password_reset' %}&quot;&gt;Forgot Password ?&lt;/a&gt;
     &lt;/div&gt;
    &lt;/form&gt;
  </code></pre>
  <p>My question how to change from username to user's email?</p>