Skip to content
Advertisement

Can’t create superuser in Django using custom user

I got this error when i try to run manage.py createsuperuser

TypeError: UserManager.create_superuser() missing 1 required positional argument: ‘username’

My User model:

JavaScript

and in my settings.py file:

JavaScript

How can i solve this? Im new in Django, documentation is confused to me…

I already tried remove AUTH_USER_MODEL = ‘usuarios.User’ or remove username attribute from class User

Advertisement

Answer

To create superuser with custom user model like above you have to implement the method create_superuser in the custom UserManager class some thing like bellow.and you need to specify username field in custom user model like bellow. Then specify the custom user model in the settings

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement