Django allauth custom login form not rendering all fields in custom user model
<p>I am trying to implement login of that consists a custom user model. Is it possible to inherit from <code>allauth.account.forms.LoginForm</code> and add a custom field to the custom login form? </p>

<blockquote>
  <p>Idea is to assign user with a role at the time of login by overriding
  login() method.</p>
</blockquote>

<p>I have followed <a href="http://django-allauth.readthedocs.io/en/latest/configuration.html" rel="nofollow noreferrer">allauth configuration</a> and mentioned what forms to use for login in settings.py with following code</p>

<pre><code>AUTH_USER_MODEL = 'core.User'
ACCOUNT_SIGNUP_FORM_CLASS = 'core.forms.SignupForm'
ACCOUNT_FORMS = {'login': 'core.forms.CoreLoginForm'}
</code></pre>

<p>I am using no auth backends other than <code>django.contrib.auth.backends.ModelBackend</code> and <code>allauth.account.auth_backends.AuthenticationBackend</code>. custom signup is working fine for me without any issues. But <strong><em>custom loginform is not rendering all fields in the user model</em></strong>. Allauth LoginForm was inherited as per accepted answer in this <a href="https://stackoverflow.com/questions/25599186/overriding-django-allauth-login-form-with-account-forms">SO Post</a> and a choicefield was added to the custom login form.</p>

<pre><code>from allauth.account.forms import LoginForm
class CoreLoginForm(LoginForm):
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super(CoreLoginForm, self).__init__(*args, **kwargs)
    role = forms.ChoiceField(widget=forms.Select(), choices=User.roles, initial=User.roles[0])
</code></pre>

<p>Upon a <code>./manage.py runserver</code> it says <code>Module "core.forms" does not define a "SignupForm" class</code>. I have already defined a SignupForm in core.forms as below and <code>signup will work if  CoreLoginForm is inherited from forms.Form instead of LoginForm</code>. So if I do </p>

<pre><code>class CoreLoginForm(forms.Form):
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super(CoreLoginForm, self).__init__(*args, **kwargs)

    role = forms.ChoiceField(widget=forms.Select(), choices=User.roles, initial=User.roles[0])
</code></pre>

<p>I can render custom login form to html page. But problem here is that I have to redefine every methods in the class including <code>authenticate()</code>, <code>perform_login()</code> etc. This will end up in copying whole LoginForm and pasting it in forms.py of the app. I dont want to do this as I think this is against DRY principle. Is there a simple way to add a custom field to custom loginform and override login() method?</p>

<p>TIA</p>