I am working on a Django 1.5 project and I have a custom model (call CustomUser ). Another application (SomeApp) must reference this user model of the user. For the purposes of ForeignKey, etc. Django documentation says use
User = settings.AUTH_USER_MODEL
However, some functions in SomeApp.models must gain access to what used to be known as User.objects . But the user is now a string, not a class, so User.objects fails. An alternative would be
from django.contrib.auth import get_user_model User = get_user_model()
Which works in other modules, but when I use this in models.py SomeApp, Django throws an error:
Incorrectly configured ("AUTH_USER_MODEL refers to the model"% s "that was not set to"% settings.AUTH_USER_MODEL)
Any ideas?
EDIT 1 - Traceback:
Traceback (most recent call last): File "<console>", line 1, in <module> File "...\django-badger\badger\__init__.py", line 7, in <module> from badger.models import Badge, Award, Progress File "...\django-badger\badger\models.py", line 26, in <module> User = get_user_model() File "...\lib\site-packages\django\contrib\auth\__init__.py", line 127, in get_user_model raise ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL) ImproperlyConfigured: AUTH_USER_MODEL refers to model 'MyApp.AuthUser' that has not been installed
Settings 2 - INSTALLED_APPS:
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'south', 'MyApp', # this is where my user model is defined 'SomeApp', # I try to use get_user_model() in this app models.py; doesn't work. 'social_auth', )