简体   繁体   中英

Serving django Admin files with Apache and mod_wsgi

I'm having trouble getting Apache to serve the admin media for django (using ver. 1.1). My ADMIN_MEDIA_PREFIX is set to the default:

ADMIN_MEDIA_PREFIX = '/media/'

And I've modified my Apache setup:

Alias /media/ /usr/lib/pymodules/python2.6/django/contrib/admin/media/

<Directory /usr/lib/pymodules/python2.6/django/contrib/admin/media/>
     AllowOverride None
     Options None
     Order allow,deny
     Allow from all
 </Directory>

I'm not entirely sure what's going on here and why it isn't working. I've seen a lot of questions like this asked, but can not determine why I'm still having the problem.

EDIT: Apache logs

[Sun Mar 11 20:14:18 2012] [notice] Graceful restart requested, doing restart
[Sun Mar 11 20:14:18 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:18 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:18 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:18 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:18 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:18 2012] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.14 with Suhosin-Patch mod_wsgi/2.8 Python/2.6.5 configured -- resuming normal operations
[Sun Mar 11 20:14:23 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:23 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Sun Mar 11 20:14:35 2012] [error] Exception KeyError: KeyError(-1220142448,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored

Django 1.3 added new cotrib app django.contrib.staticfiles:

https://docs.djangoproject.com/en/dev/releases/1.4/

"Django will now expect to find the admin static files under the URL /admin/", so now ADMIN_MEDIA_PREFIX is deprecated - alias in Apache setup is sufficient, ex:

Alias /static/admin/ /usr/lib/pymodules/python2.6/django/contrib/admin/media/

This works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM