0
votes

I'm new to Django, and I'm trying to learn how to use it. I've hit a brick wall trying to launch the admin site.

I'm working out of /opt/django/mysite.com/proj1

I'm just trying to use the built-in webserver, so python manage.py runserver

The admin page will load, but it's missing base.css and dashboard.css.

These files are located in /usr/lib/python2.7/site-packages/django/contrib/admin/media/

Seeing that it seems like ADMIN_MEDIA_PREFIX typically needs to be set, I've tried ADMIN_MEDIA_PREFIX = '/usr/lib/python2.7/site-packages/django/contrib/admin/media/' to no effect.

Could someone help me fix this problem?

Thanks,

Edit: The GET requests where I'm seeing errors are http://localhost:8000/admin/media/css/base.css http://localhost:8000/admin/media/css/dashboard.css

3
ADMIN_MEDIA_PREFIX should be URL prefix, not the actual path. Are you using 1.3 or trunk? - jholster
Using 1.3.1. In that case, I assume that I need to link that the usr/lib/... directory somewhere in my /opt/django/mysite.com/proj1 hierarchy. - fandingo
The default value in 1.3 is ADMIN_MEDIA_PREFIX = '/static/admin/'. Did you try that? - jholster
You can also supply the admin media path by manage.py --adminmedia, but again, the defaults should work. - jholster
Do you use development web server or apache? If you use apache error logs could help to resolve this issue. - Ivan Kolodyazhny

3 Answers

1
votes

It looks like your admin media files are located in the default directory. Try this:

ADMIN_MEDIA_PREFIX = '/media/

For more information look to the Django docs: https://docs.djangoproject.com/en/1.3/ref/settings/#admin-media-prefix

0
votes

I went ahead and just configured mod_wsgi with Apache. It works okay, but I'd still like advice if there is a better way to configure it.

<VirtualHost *:80>
    ServerName mysite.com

    WSGIDaemonProcess apache processes=2 maximum-requests=500 threads=2
    WSGIProcessGroup apache
    WSGIScriptAlias / /opt/django/fmysite.com/proj1/apache.wsgi

    Alias /admin/media/ /usr/lib/python2.7/site-packages/django/contrib/admin/media/

</VirtualHost>
0
votes

Note that this answer is now obsolete for Django 1.4+ as ADMIN_MEDIA_PREFIX is now obsolete. For more information, see the release notes for Django 1.4