AUTH_USER_MODEL refers to model .. that has not been installed and created AbstractUser models not able to login AUTH_USER_MODEL refers to model .. that has not been installed and created AbstractUser models not able to login python python

AUTH_USER_MODEL refers to model .. that has not been installed and created AbstractUser models not able to login


I've run into this a few times. It's always been an import issue. Suppose we have core/models.py that implements a custom user and imports a symbol from another file (say Else):

from Something import Elseclass CustomUser(AbstractBaseUser):    pass

And then we have another file that uses CustomUser and also defines Else. Let's call this something/models.py:

from core.models import CustomUserclass Else(models.Model):    passclass AnotherClass(models.model):    user = models.ForeignKey(CustomUser)

When core/models.py goes to import Else, it evaluates something/models.py and runs into the AnotherClass definition. AnotherClass uses CustomUser, but CustomUser hasn't been installed yet because we're in the process of creating it. So, it throws this error.

I've solved this problem by keeping my core/models.py standalone. It doesn't import much from my other apps.


Ok there were three issues here for me, so I'm going to address all of them since I am pretty sure the first two will come up for someone else.

  • Manager isn't available; User has been swapped for 'poker.PokerUser'

This was due to using but not recreating the UserCreationForm. When using custom models in 1.5, some model forms are available out of the box but this one must be recreated. See here for the docs.

  • The Manager isn't available; User has been swapped for 'poker.PokerUser'

While I had AUTH_USER_MODEL = 'poker.PokerUser' set in my settings.py, I was calling get_user_model() from the poker.models location. You must call get_user_model() from a different location. Moving my form to registration.forms and calling get_user_model() from there worked correctly.

  • New users not saving

This was just a brain fart on my end. In my UserRegistration model I was manipulating various fields from the form. When I passed those fields back to UserCreationForm for the save() method, I was not passing the password fields with it. Woops!


It can happen if you forget to register your app in settings. In your settings.py file add the name of your app in the list of INSTALLED_APPS. I hope this helps.

For instance, if your app name is 'users' it would look like this:

INSTALLED_APPS = [  ......  'users']