I have a site with Django running some custom apps. I was not using the Django ORM, just the view and templates but now I need to store some info so I created some models in one app and enabled the Admin.
The problem is when I log in the Admin it just says "You don't have permission to edit anything", not even the Auth app shows in the page. I'm using the same user created with syncdb as a superuser.
In the same server I have another site that is using the Admin just fine.
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 all in Gentoo Linux 2.6.23
Any ideas where I can find a solution?
Thanks a lot.
UPDATE: It works from the development server. I bet this has something to do with some filesystem permission but I just can't find it.
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 run python manage.py from /var/django/gpx directory
- The site is GPX, one of the apps is contable and lives in /var/django/gpx/contable
- the user apache is webdev group and all these directories and files belong to that group and have rw permission
UPDATE 4: confirmed that the settings file is the same for apache and runserver (renamed it and both broke)
UPDATE 5: /var/django/gpx/contable/init.py exists
This is the relevan part of urls.py:
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('gpx',
(r'^$', 'menues.views.index'),
(r'^adm/$', 'menues.views.admIndex'),
Hopefully this helps someone, but we had this same problem because someone added a different authentication backend to settings.py and did not keep the default ModelBackend. Changing the setting to:
fixed it for us.
I had the same problem, my settings file was like follow:
I forgot to add
,
afterdjango_newsfeed
Make sure you have added your application to settings.INSTALLED_APPS.
The django template for the admin app index page reads:
That must be your problem.
EDIT: Either that or you are not logged in as the user you say you are. Can you look in the database and make sure that the auth_user.is_superuser for the user in question has a value of 1?
EDIT: If you user is_staff and is_superuser are marked as 1 in the DB, and you are sure you are logged in as that user; is it possible that you are only seeing this in production (i.e. under apache) and that your settings.py for production is different than in development?
EDIT: So you have different behavior in dev and production. I can think of two scenarios:
a) You have a different settings.py for production. Can you edit your question showing the relevant portion of your httpd.conf? It should be something like:
Also, what is your PYTHONPATH?
What is the SetEnv line saying? Is it pointing to the very same module you have in development? Are you sure in your PYTHONPATH you have
mysite.settings
as the file you think you have?b) You have a PYTHONPATH problem in production and the apps can't be found. This should generate a much more severe error though...
Questions:
Try accessing your database and in the table auth_user make sure that the fiels is_staff, is_active and is_superuser are marked as true (1) for your user.
It sounds like you haven't registered any apps with the admin (step 5 in this overview).
Try adding the line
admin.autodiscover()
to your main urls.py, making sure to dofrom django.contrib import admin
first.For example:
You can also register your models individually with
admin.site.register(YourModel)
.We encountered the same problem when installing django 1.1 over an old installation of django 0.96
it was solved when we made a fresh install