Take the 2-minute tour ×

Being a beginner of using Django, i am trying to add some module for the purpose of testing Django, but I've got a problem regarding the importError which I've googled for solution with no success. Below is my situation

The project is created to my PC J:\ while the python package is installed on C:. According to guardian's installation guide following code have to be added in django's backend:

'django.contrib.auth.backends.ModelBackend', # default

The problem's come, when I put the guardian's app under the directory of mysite, configurate the install_apps setting with 'guardian' and start syncdb, the error claim as below which i believe that it is because the django's filw do not understand what is "guradian" really is

File "J:\mysite\guardian\conf\settings.py", line 6, in raise ImproperlyConfigured("In order to use django-guardian's " django.core.exceptions.ImproperlyConfigured: In order to use django-guardian's O bjectPermissionBackend authorization backend you have to configure ANONYMOUS_USE R_ID at your settings module

So, I move the 'guardian' folder under Django's contrib folder, adding the sys path and configurate the install_app setting with 'django.contrib.guardian'. However, I end up with the importerror.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

As it seems from the error message, you need to add the user id for anonymous user for you site.

Create a user (named maybe anonymous) and put the id of user in the settings.py file.
Obtain the user id from the database using the shell.

Put the id in the settings file:

ANONYMOUS_USER_ID = <Your anonymous USER_ID>


Just looked through the documentation of the django-guardian app. It also specifies this:

share|improve this answer
Thanks!!!!!!, the problem is fixed by creating ANONYMOUS_USER_ID = -1 in the setting.py. Thank!!!!!!!! –  user563824 Jan 5 '11 at 12:41
add comment

Your Answer


