I’m not sure why this isn’t working, since it seems to be exactly what the django documentation tells me to do.
I want to be able to subclass the built-in User model so that I can add extra fields to it.
from django.contrib.auth.models import User
class Person(User):
my_extra_field = models.CharField(max_length=30)
#...
This seems rather simple, and the way I understand it, all the methods of User should be available to Person. However, calling
user = Person.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
in the django shell results in an error.
Is this just a quirk of the shell (I’m using iPython), or am I doing something wrong?
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/
You need to include the UserManager(). Import the User, UserManager and set the UserManager() to the variable objects in your Person class.