'django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
After migrating my django and userena packages like below
Django 1.8 to Django 1.9.7
django-userena 1.4.1 to django-userena==2.0.1
After running the project , I am getting below this error
Unhandled exception in thread started by <function wrapper at 0xb689641c>
Traceback (most recent call last):
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/Documents/swamy/sample_project/july/5/sample11/sampleapp/urls.py", line 28, in <module>
(r'^grappelli/', include('grappelli.urls')),
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/grappelli/urls.py", line 8, in <module>
from .views.switch import switch_user
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/grappelli/views/switch.py", line 18, in <module>
User = get_user_model()
File "/home/Documents/environments/venv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 155, in get_user_model
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
Here are INSTALLED_APPS in my settings file,
'grappelli.dashboard',
'grappelli',
'filebrowser',
'django.contrib.admindocs',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'django.contrib.redirects',
'django.contrib.sitemaps',
'haystack',
'memcache_status',
'stheme',
'home',
'customers',
'orders',
#'legacy',
'products',
'bloglets',
'utils',
'catax',
'sqls',
'quotes',
#'django_stylus',
#'djgrid',
#'obdjects',
'quickpages',
'loginas',
#'pyjade',
'django_countries',
'debug_toolbar',
'djide',
#'dbtemplates',
#'aloha', # out temporarily, migrate to alternate https://github.com/ntucker/django-aloha-edit - JJW
'coffeescript',
'django_wysiwyg',
#'django_bfm',
'userena',
'guardian',
#'apps',
#'filer',
'easy_thumbnails',
'taggit',
#'taggit_templatetags',
# 'social_auth',
'social.apps.django_app.default',
#'socialregistration',
#'socialregistration.contrib.linkedin',
'email_extras',
#'csvimport',
'csvimport.app.CSVImportConf',
'django_extensions',
'webshell',
'easy_select2',
#'plata',
#'plata.contact',
#'plata.discount',
#'plata.payment',
#'plata.shop',
'lastmodule',
I guess there are some changes in python apps.But I can't find the reason... Does anyone help to fix this issue ?
Thanks In Advance !
Solution 1:[1]
This problems generally resides between 2 reasons.
- When the dependencies order in installed apps are reversed.
- When you haven't mentioned the dependency in the installed apps at all.
Here in this case grappelli seems to raise the issue telling auth.User
not found. It means it is not able to find any package auth
. If you are using the default user model remove that AUTH_USER_MODEL
setting from the config or if you are using any custom user model in package 'auth' list it in installed apps.
Solution 2:[2]
A complete traceback would help to diagnose it better. Prima facie, it seems to me as a dependency issue caused due to migration. Check what Django docs have to say about this -
Due to limitations of Django’s dynamic dependency feature for swappable models, you must ensure that the model referenced by AUTH_USER_MODEL is created in the first migration of its app (usually called 0001_initial); otherwise, you will have dependency issues.
Here's the link - https://docs.djangoproject.com/en/1.9/topics/auth/customizing/
Solution 3:[3]
if your application is not called auth you have to replace it:AUTH_USER_MODEL='your_app_name.User'
Solution 4:[4]
Once I had the same issue in v-2.2 then I realized that the spelling of "register" in the admin.py file was wrong.
Solution 5:[5]
This is becuase you have an app 'auth' in which you have defined your user model. and You have not mentioned app name in INSTALLED_APPS dictionary.
Try Adding your app name in INSTALLED_APPS and check.
Solution 6:[6]
This error may also appear due to a missing import of a model in an admin.py (Django version 2.2).
Solution 7:[7]
I doubt this is the typical answer, but I hit this problem when I using reverse
and should have been using reverse_lazy
. Changing to reverse_lazy
fixed it for me.
Solution 8:[8]
This error appeared when I had an improperly configured model and added it to the admin backend.
Wrong:
class VolunteerExperience:
...
Correct:
class VolunteerExperience(models.Model):
...
I hope this helps someone who gets misdirected by the exception message "django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed"
Now I know that this message most likely indicates an incorrectly configured model.
Solution 9:[9]
In addition to all the other answers, I ran into this issue when I upgraded Django. I had an import that was deprecated from one release to another. Make sure to check the release notes/version histories before upgrading any package.
Solution 10:[10]
Make sure you write your code of custom user in models.py
file.
Solution 11:[11]
Try make the migrations first; python manage.py makemigrations. This might detect if you have any problems with your imports which you can fix then run the server to verify
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow