Django Admin: do not see applications (permission problem?)

I have a site with Django that runs some custom applications. I did not use Django ORM, just presentation and templates, but now I need to save some information, so I created several models in one application and enabled Admin.

The problem is that when I log into Admin, it just says: "You do not have permission to edit anything," even the Auth application does not appear on the page. I am using a single user created using syncdb as root.

On the same server, I have another site that just uses admin.

Using Django 1.1.0 with Apache / 2.2.10 mod_python / 3.3.1 Python / 2.5.2 with psql (PostgreSQL) 8.1.11 everything in Gentoo Linux 2.6.23

Any ideas where I can find a solution?

Many thanks.

UPDATE: it works with the development server. I bet this has something to do with some file system permissions, but I just can't find them.

UPDATE2: vhost configuration file:

<Location /> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE gpx.settings PythonDebug On PythonPath "['/var/django'] + sys.path" </Location> 

UPDATE 3: more info

  • / var / django / gpx / init .py exists and is empty
  • I am running python manage.py from the directory / var / django / gpx
  • GPX site, one of the applications is contable and lives in / var / django / gpx / contable
  • the apache user is a webdev group, and all of these directories and files belong to this group and have rw permission

UPDATE 4: confirmed that the settings file is the same for apache and runerver (renamed it and both broke)

UPDATE 5: / var / django / gpx / contable / init .py exists

This is the relevant part of urls.py:

 urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns('gpx', (r'^$', 'menues.views.index'), (r'^adm/$', 'menues.views.admIndex'), 
+6
python django django-admin permissions
source share
6 answers

Hope this helps someone, but we had the same problem because someone added another authentication server in settings.py and did not save the standard ModelBackend file. Change setting to:

 AUTHENTICATION_BACKENDS = ( 'auth.authentication.EmailBackend', 'django.contrib.auth.backends.ModelBackend', ) 

fixed it for us.

+22
source share

It looks like you have not registered any applications with an administrator (step 5 in this review ).

Try adding the line admin.autodiscover() to the main urls.py by doing from django.contrib import admin .

For example:

 # Other imports... from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', ('^admin/', include(admin.site.urls)), # Other URL patterns... ) 

You can also register your models individually using admin.site.register(YourModel) .

+11
source share

Make sure you add your application to settings.INSTALLED_APPS.

Django template for admin app index page:

 {% if app_list %} {% for app in app_list %} ... {% else %} <p>{% trans "You don't have permission to edit anything." %}</p> {% endif %} 

That should be your problem.


EDIT: either this or you are not logged in as the user you are talking to. You can look in the database and make sure that auth_user.is_superuser for this user has a value of 1?


EDIT: if the user is_staff and is_superuser are marked as 1 in the database, and you are sure that you are logged in as this user; Is it possible that you see this only during the production process (i.e., under apache) and that your production settings.py are different from development?


EDIT: So you have different behavior in dev and production. I can imagine two scenarios:

a) You have another settings.py file for production. Can you change your question by specifying the appropriate part of your httpd.conf? It should be something like:

 <Location "/mysite/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonOption django.root /mysite PythonDebug On </Location> 

Also what is your PYTHONPATH?

What does the string SetEnv say? Does this indicate the same module that you have in development? Are you sure that in PYTHONPATH you have mysite.settings as the file you think you have?

b) You have a problem with PYTHONPATH and the applications cannot be found. This should lead to a much more serious error, though ...


Questions:

  • / var / django / gpx has init .py right?
  • Is /var/django/gpx/settings.py the same file as when working with manage.py runningerver?
  • What is the name of your application in / var / django /?
  • Does the user running Apache have permissions for all of these directories?
+2
source share

Try to access your database and in the auth_user table make sure that fiels is_staff, is_active and is_superuser are marked as true (1) for your user.

+2
source share

We encountered the same problem when installing django 1.1 on top of the old django 0.96 installation

it was solved when we did a new installation

0
source share

I had the same problem, my settings file looked like this:

  PROJECT_APPS = ( 'app1', 'app2', ) 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.flatpages', # django-allauth settings 'allauth', 'allauth.account', 'allauth.socialaccount', # auth providers 'allauth.socialaccount.providers.facebook', 'storages', 'compressor', 'south', 'gunicorn', 'kombu.transport.django', 'djcelery', 'django_nose', 'raven.contrib.django.raven_compat', 'djrill', 'django_newsfeed' ) + PROJECT_APPS 

I forgot to add , after django_newsfeed

0
source share

All Articles