2

In my django project I've created a customized models for User and its manager class. I named them User (which inherits from AbstractUser) and UserManager (which inherits from BaseUserManager). Given that these are the default django's name for those models, is there any problem in that? I run the following form django shell:

>>>from django.contrib.auth import get_user_model
>>>user = get_user_model() 
>>>user.objects

These are the outputs:

<class 'myapp.models.models.User'>
<class 'myapp.models.models.UserManager'>

Apparently no conflicts are shown, so it seems to be all right. I hope some django experts could confirm me I won't have any surprise later on through the development.

dc_Bita98
  • 851
  • 2
  • 17
  • 35

1 Answers1

1

There is no problem with that.

However, you have to tell Django that you've done a custom User model and want to use it by defining the AUTH_USER_MODEL setting in your settings.py file.

AUTH_USER_MODEL = '<name_of_your_app>.<name_of_your_user_model'

In a project of mine, I did : AUTH_USER_MODEL = 'base.User' for instance.

More info in official documentation HERE

lbris
  • 1,068
  • 11
  • 34