Django Creating Super User Error: Attributeerror: 'profilemanager' Object Has No Attribute 'create_superuser'
Hi I am trying to create a superuser, however, after I added my own ProfileManager I get the error: AttributeError: 'ProfileManager' object has no attribute 'create_superuser' But
Solution 1:
BaseUserManager
class does not have create_superuser
nor create_user
, these methods are implemented in UserManager
Which is also documented in customizing authentication documentation
If your user model defines username, email, is_staff, is_active, is_superuser, last_login, and date_joined fields the same as Django’s default user, you can install Django’s UserManager; however, if your user model defines different fields, you’ll need to define a custom manager that extends BaseUserManager providing two additional methods:
create_user
create_superuser
So you don't need to set objects attribute nor override anything as AbstractUser
sets objects attribute to
objects = UserManager()
Solution 2:
No, BaseUserManager
doesn't have that method, but UserManager
does
from django.contrib.auth.models import UserManager
classProfileManager(UserManager):
pass
Post a Comment for "Django Creating Super User Error: Attributeerror: 'profilemanager' Object Has No Attribute 'create_superuser'"