Mezgrman
Mezgrman

Reputation: 886

Django admin interface not working in Apache2

I setup Django 1.4 on my testing server and everything works fine, except for the admin interface, which returns either a 404 or 403 error, depending on my configuration.

I also noticed that the "static/admin" directory only contains css, js and img directories.

Any help would be greatly appreciated!

EDIT Here's the relevant part of my apache configuration:

DocumentRoot /home/jmetzler/www/public

WSGIDaemonProcess mezgrvm python-path=/home/jmetzler/www/private/py-bin:/home/jmetzler/www/private/py-bin/mezgrman:/usr/lib/python2.7/site-packages processes=1 threads=1 display-name=%{GROUP}
WSGIProcessGroup mezgrvm
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /home/jmetzler/www/private/py-bin/mezgrman/wsgi.py

Alias /admin /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin

Alias /images /home/jmetzler/www/public/images
Alias /css /home/jmetzler/www/public/css
Alias /error /home/jmetzler/www/public/error

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /home/jmetzler/www/public/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 410 /error/410.html
    ErrorDocument 500 /error/500.html
</Directory>

Upvotes: 0

Views: 564

Answers (1)

Rohan
Rohan

Reputation: 53336

I don't think Alias /admin /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin is appropriate in the apache conf.

Your urls.py should be appropriately handling it like url(r'^admin/', include(admin.site.urls)),

If you want to handle static files for admin site, they should reside in your static directory, either symlinked or copied.

If you are symlinking admin media, then you should add Options +FollowSymLinks in Directory element. e.g.

<Directory "/home/user1/website1/static">
        Order allow,deny
        Options Indexes +FollowSymLinks
        Allow from all
        IndexOptions FancyIndexing
</Directory>

Upvotes: 1

Related Questions