Monday, August 28, 2017

trying to create allauth SignupForm subclass for customization....

Hello, I'm trying to add some additional fields to the allauth signup form (first_name and last_name). I'm thinking the best way to do this is to create a allauth SignupForm subclass and add my own fields (very new to django so please let me know if I'm going about this wrong)

I added

ACCOUNT_SIGNUP_FORM_CLASS = 'accounts.forms.UserCreateForm'

to my base settings file

and here is my

from django.contrib.auth import get_user_model
from allauth.account.forms import SignupForm
from django import forms

class UserCreateForm(SignupForm):
    class Meta:
        fields = ("first_name", "last_name", "email", "username", "password1", "password2")
        model = get_user_model()
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields["first_name"].label = ''
        self.fields["first_name"].widget.attrs["placeholder"] = "First Name"
        self.fields["last_name"].label = ''
        self.fields["last_name"].widget.attrs["placeholder"] = "Last Name"
        self.fields["email"].label = ''
        self.fields["email"].widget.attrs["placeholder"] = "Email"
        self.fields["username"].label = ''
        self.fields["username"].widget.attrs["placeholder"] = "Username"
        self.fields["password1"].label = ''
        self.fields["password1"].widget.attrs["placeholder"] = "Password"
        self.fields["password2"].label = ''
        self.fields["password2"].widget.attrs["placeholder"] = "Confirm Password"

for some reason I keep getting the error ...

django.core.exceptions.ImproperlyConfigured: Error importing form class accounts.forms: "cannot import name 'SignupForm'"

Not sure why. Obviously there is a SignupForm in, seen here...

I dont know what I'm doing wrong. Any help you can give is much appreciated

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment