Django-guardian: "ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed".

Created on 12 Feb 2014  ·  2Comments  ·  Source: django-guardian/django-guardian

Hi,

I'm probably doing something wrong here so apologies in advance!

I followed the installation and configuration steps in the documentation. It fails to assign permissions with the "ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed".

I've read the related Django docs and understand that the AUTH_USER_MODEL setting uses the "app_label.UserModel" format when using a custom user model. I'm not using a custom user model but the default django one.

All issues and solutions I found in the internets were related to custom user models which I don't think applies to me.

I'm using django 1.6.1 and django-guardian 1.1.1.

I tried to set the settings.AUTH_USER_MODEL = 'guardian.User' to no avail.

Any help appreciated!

Cheers

These are the exact steps (after setting database config, I'm using here the default django permissions but I get the same result with permissions defined in the Meta class of the model)

from django.contrib.auth.models import User
john = User.objects.get(id=2)
john

from mtm.models import Sharing
obj = Sharing.objects.get(id=1)
obj

john.has_perm('mtm.change_sharing', obj)
False
from guardian.shortcuts import assign_perm
assign_perm('mtm.change_sharing', john, obj)
Traceback (most recent call last):
File "", line 1, in
assign_perm('mtm.change_sharing', john, obj)
File "/usr/local/lib/python2.7/dist-packages/guardian/shortcuts.py", line 71, in assign_perm
user, group = get_identity(user_or_group)
File "/usr/local/lib/python2.7/dist-packages/guardian/utils.py", line 73, in get_identity
if isinstance(identity, get_user_model()):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/init.py", line 129, 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 'auth.User' that has not been installed

All 2 comments

Fixed it by installing south and running manage.py migrate. I don't know if this is specific to my setup. If not you may want to update the config guide.

Cheers!

The most common reason for this error:
when you accidently mentioned your app name in MIDDLEWARE instead of INSTALLED_APPS, go in your settings.py file and check for this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

David-OConnor picture David-OConnor  ·  6Comments

lukaszb picture lukaszb  ·  14Comments

g-as picture g-as  ·  10Comments

ad-m picture ad-m  ·  13Comments

brianmay picture brianmay  ·  16Comments