Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed". #198

Closed
karolpivo opened this issue Feb 12, 2014 · 2 comments

Comments

@karolpivo
Copy link

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
<User: john>
from mtm.models import Sharing
obj = Sharing.objects.get(id=1)
obj
<Sharing: Sharing object>
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 "<pyshell#21>", 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

@karolpivo
Copy link
Author

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!

@YashMarmat
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants