0

I am trying to configure a custom user using django-allauth and have created the following signup form in a new app customforms

#settings.py
ACCOUNT_SIGNUP_FORM_CLASS = 'custom_forms.SignupForm'

#custom_forms/models.py
from django import forms
from django.contrib.auth import get_user_model

class SignupForm(forms.Form):
    first_name = forms.CharField(max_length=30, label='Voornaam')
    last_name = forms.CharField(max_length=30, label='Achternaam')
    bio= forms.CharField(max_length=500)
    email = forms.EmailField(max_length=254)
    password=forms.CharField(label=("Password"), widget=forms.PasswordInput)
    password_confirm=forms.CharField(widget=forms.PasswordInput)

class Meta:
    model = get_user_model() 

def save(self, user):
    user.first_name = self.cleaned_data['first_name']
    user.last_name = self.cleaned_data['last_name']
    user.bio= self.cleaned_data['bio']
    user.email= self.clean_data['email']

    user.save()

I am currently getting the following error: Module "custom_forms" does not define a "SignupForm" class. when I change the path to myapp.custom_forms.SignupForm I get: Error importing form class toteachhisown.custom_forms: "No module named custom_forms". Any ideas/help is much appreciated.

user1532761
  • 29
  • 1
  • 7
  • is this the exact code ? Or is the indentation of `class Meta` slightly off ? Also, if you are defining `model=`, you should be using a `forms.ModelForm` instead of `forms.Form`. ALso, this post could give you some insights: http://stackoverflow.com/questions/4048618/django-error-improperlyconfigured-module-does-not-define-a-class – karthikr Nov 21 '13 at 15:58
  • Ahh, thank you so that question helped. It was that I had to include models in the path, like so custom_forms.models.SignupForm. – user1532761 Nov 21 '13 at 16:08

1 Answers1

0

The solution was that I needed to include .models in the path like so: custom_forms.models.SignupForm.

user1532761
  • 29
  • 1
  • 7