0

I'm trying to custom the AllAuth interface. I can override LoginForm and SignupForm separately, but if I override both of them, I got this error :

Module "app.forms" does not define a "BootstrapSignupForm" class

my forms :

class BootstrapLoginForm(LoginForm):
     def __init__(self, *args, **kwargs):
        super(BootstrapLoginForm, self).__init__(*args, **kwargs)
        self.fields['login'].widget.attrs['class'] = 'form-control';
        self.fields['login'].widget.attrs['placeholder'] = 'User name';

        self.fields['password'].widget.attrs['class'] = 'form-control';
        self.fields['password'].widget.attrs['placeholder'] = 'Password';

class BootstrapSignupForm(SignupForm):
     def __init__(self, *args, **kwargs):
        super(BootstrapSignupForm, self).__init__(*args, **kwargs)
        self.fields['username'].widget.attrs['class'] = 'form-control';
        self.fields['username'].widget.attrs['placeholder'] = 'user name';

my settings.py

ACCOUNT_FORMS = {'login': 'app.forms.BootstrapLoginForm'}
ACCOUNT_SIGNUP_FORM_CLASS = 'app.forms.BootstrapSignupForm'

But if I only keep one of them, it works. Why is it not possible to override many of allauth forms at the same time ? Is there a workaround ? What is the googd practice to change AllAuth theme ? Is there a easy way to set up bootstrap ?

Ben
  • 3,972
  • 8
  • 43
  • 82

1 Answers1

1

The ACCOUNT_SIGNUP_FORM_CLASS represents a form that contains a few additional fields that are added to the signup form. So, it does not actually replace the real signup form, its fields only get merged into it.

If you really want to replace the actual forms, then you should indeed use ACCOUNT_FORMS. Simply add a signup key in there. Do note that there is also a SOCIALACCOUNT_FORMS to take care of ...

See How to customize user profile when using django-allauth for details on ACCOUNT_SIGNUP_FORM_CLASS.

Community
  • 1
  • 1
pennersr
  • 6,306
  • 1
  • 30
  • 37
  • thank you! And I suggest django-widget-tweaks, it's a good way to edit forms fields classes. – Ben Aug 17 '16 at 14:40