title: How to extend Django AuthenticationForm
body: <p>I'm writing a web app and I want to add a required checkbox to Django's AuthenticationForm</p>
  
  <p>I don't know how to extends (or override ?) the AuthenticationForm.</p>
  
  <p>Here's where I call the auth form in my template :</p>
  
  <pre><code>&lt;h2&gt;Login&lt;/h2&gt;
  &lt;form method="post"&gt;
     {% csrf_token %}
     {{ form.as_p}}
     &lt;button type="submit" class="btn btn-success"&gt;Login&lt;/button&gt;
   &lt;/form&gt;
    &lt;br&gt;
   &lt;p&gt;&lt;strong&gt;-- OR --&lt;/strong&gt;&lt;/p&gt;
   &lt;a href="{% url 'social:begin' 'github' %}"&gt;Login with GitHub&lt;/a&gt;&lt;br&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Here's my urls.py :</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  from django.contrib.auth import views as auth_views
  from django.conf.urls import url, include
  from gitInsights import views as core_views
  from django.contrib.auth.views import LoginView
  
      urlpatterns = [
      path('admin/', admin.site.urls),
      path('gitInsights/', include('gitInsights.urls')),
      path('login/', auth_views.login, name='login'),
      path('logout/', auth_views.logout, name='logout'),
      url(r'^auth/', include('social_django.urls', namespace='social')),
      url(r'^settings/$', core_views.settings, name='settings'),
      url(r'^settings/password/$', core_views.password, name='password'),
      path('', core_views.index, name='index'),
      path('informations-legales/', core_views.informations_legales, name='informations_legales'),
  ]
  </code></pre>
  
  <p>And here's my views.py, and I'm also using python social auth to login the user :</p>
  
  <pre><code>    @login_required
      def index(request):
  
          form = InfosForm(request.POST or None)
  
          if form.is_valid():
  
              #if request.user.is_authenticated:
              #    gituser = request.user.social_auth.filter(provider ='github-oauth2')
              #    extra_data = str(gituser.extra_data['access_token'])
  
              g = Github(gitkey)
  
              try:
  
                  orga_name = form.cleaned_data['orga_name']
                  org = g.get_organization(orga_name)
                  repos = org.get_repos()
                  reposList = []
                  totalCommits = []
                  #Transformation de la PaginatedList en liste classique pour manipuler   facilement les repos
                  for repo in repos:
                      commitsList = repo.get_stats_participation().all
                      languages = repo.get_languages()
                      if not languages:
                          top_language = ''
                      else:
                          top_language = max(languages.keys(), key=(lambda key: languages[key]))
                      repository = Repository(titre=repo.name, starsgazers=repo.stargazers_count, top_language=top_language)
                      if len(commitsList) &gt;= 2:
                          repository.commits_this_week = commits_this_week=commitsList[-1]
                          repository.commits_last_week = commits_last_week=commitsList[len(commitsList)-2]
                      reposList.append(repository)
                  reposList.sort(key=lambda x: x.starsgazers, reverse=True)
                  reposList = reposList[:10]
                  #django jchart
                  envoi = True
  
              except UnknownObjectException :
                  erreur = True
  
          return render(request,'gitInsights/index.html', locals())
  
      def get_total_commits_last_week(reposList):
  
          totalCommits = []
          for repo in reposList:
              totalCommitsAllWeeks = repo.get_stats_participation().all
              totalCommits.append(totalCommitsAllWeeks[-1])
  
          return totalCommits
  
      @login_required
      def settings(request):
          user = request.user
  
          try:
              github_login = user.social_auth.get(provider='github')
          except UserSocialAuth.DoesNotExist:
              github_login = None
  
          can_disconnect = (user.social_auth.count() &gt; 1 or user.has_usable_password())
  
          return render(request, 'settings.html', {
              'github_login': github_login,
              'can_disconnect': can_disconnect
          })
  
      @login_required
      def password(request):
          if request.user.has_usable_password():
              PasswordForm = PasswordChangeForm
          else:
              PasswordForm = AdminPasswordChangeForm
  
          if request.method == 'POST':
              form = PasswordForm(request.user, request.POST)
              if form.is_valid():
                  form.save()
                  update_session_auth_hash(request, form.user)
                  messages.success(request, 'Your password was successfully updated!')
                  return redirect('password')
              else:
                  messages.error(request, 'Please correct the error below.')
          else:
              form = PasswordForm(request.user)
          return render(request, 'password.html', {'form': form})
  
  
      def informations_legales(request):
          return render(request, 'gitInsights/informations_legales.html')
  </code></pre>
  
  <p>Thanks by advance !</p>