[Answered ]-How do I host a Django project's admin static files?

1👍

Firstly, no-one says you have to serve your admin static files from the same base path as the others. You can set ADMIN_MEDIA_PREFIX to whatever you like.

However, surely the easiest thing is just to add a symlink from your static folder to django/contrib/admin/media.

1👍

Common solution is using /media/ for admin media static files, so it could be in settings.py

ADMIN_MEDIA_PREFIX = '/media/'

and in virtual host config:

Alias /media /path/to/django/contrib/admin/media/
<Location /media>
    SetHandler None
</Location>
👤zaan

0👍

You can reverse the order of the Alias entries and Apache will parse it as intended:

Alias /static/admin /usr/local/.../django/contrib/admin/media
Alias /static /path/to/site.com/static

This is because when Apache loads its configuration, it stores entries from a top down perspective. So it first tries to match /static/admin, then if the URI doesn’t match, it then tries to match /static.

Leave a comment