I have a question about Django allauth-app. I have set up the allauth-app and have a standard login. Now I would like to store some additional information on signup. To be precise I would like to store the User's city, firstname and lastname. I tried to accomplish this task as explained in
How to customize user profile when using django-allauth
But even if I try to capture the first- and lastname where I shouldnt probably create a model, I fail due to this error:
'module' object has no attribute 'CharField'
I have put new fields in the form and did this:
ACCOUNT_SIGNUP_FORM_CLASS = 'yourproject.yourapp.forms.SignupForm'
Since I am using Django for a couple of days now it might be something very basic that I miss and I do try to read manuals but I am not close to solving this and I decided to ask you for help. Thanks in advance.
my forms.py look like this:
from django.forms import *
class SignupForm(forms.Form):
first_name = forms.CharField(max_length=30, label='Voornaam')
last_name = forms.CharField(max_length=30, label='Achternaam')
def signup(self, request, user):
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
user.save()
my models.py looks like this:
from django.db import models
from django.contrib.auth.models import User
from django.db import models
from allauth.account.models import EmailAddress
class Profile(models.Model):
user = models.OneToOneField(User, verbose_name=_('user'), related_name='profiles')
first_name=models.CharField(_("First Name"), max_length=150)
last_name=models.CharField(_("Last Name"), max_length=150)
The error appears in this line:
first_name = forms.CharField(max_length=30, label='Voornaam')
Aftermath --> The import statement in my forms is wrong. It should rather look like this:
formy.py:
from django import forms