I'm trying to include custom fields for the Django allauth SignUp form without much success. I've created the following forms and models:
models.py
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class UserProfile(models.Model):
user = models.OneToOneField(User, related_name='profile', unique=True)
# The additional attributes we wish to include.
website = models.URLField(blank=True)
picture = models.ImageField(upload_to='profile_images', blank=True)
def __unicode__(self):
return self.user.username
forms.py
from django.contrib.auth import get_user_model
from django import forms
from .models import UserProfile
class SignupForm(forms.ModelForm):
class Meta:
model = get_user_model()
fields = ('username', 'password', 'email', 'website', 'picture')
def save(self, user):
profile.save()
user.save()
settings.py
AUTH_USER_MODEL = 'user_app.UserProfile'
ACCOUNT_SIGNUP_FORM_CLASS = 'user_app.forms.SignupForm'
I've receiving the following error: AttributeError: type object 'UserProfile' has no attribute 'REQUIRED_FIELDS'
- Is this the correct way to extend the base class?
- For the profile page, how do I load the extended class instead of the user class, so that I can display the username that is logged in?