I'm using django-allauth and I want to be able to add new field to my User model. What's the best way to do this as of you ?
2 Answers
See the docs Storing additional information about users, Make a model with OneToOneField relation to User.
from django.contrib.auth.models import User class UserProfile(models.Model): # This field is required. user = models.OneToOneField(User) # Other fields here accepted_eula = models.BooleanField() favorite_animal = models.CharField(max_length=20, default="Dragons.") 1 Comment
Enrique Bruzual
user = models.OneToOneField(User) will throw an error, you need to add on_delete= as in user = models.OneToOneField(User, on_delete=models.CASCADE)