使用Apache和mod_wsgi提供django Admin文件

时间:2012-03-12 00:18:13

标签: python django apache django-admin mod-wsgi

我无法让Apache为django提供管理媒体服务(使用版本1.1)。我的ADMIN_MEDIA_PREFIX设置为默认值:

ADMIN_MEDIA_PREFIX = '/media/'

我修改了我的Apache设置:

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>

我不完全确定这里发生了什么,为什么它不起作用。我已经看到很多像这样问的问题,但无法确定我为什么还有这个问题。

编辑:Apache日志

[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

1 个答案:

答案 0 :(得分:0)

Django 1.3添加了新的cotrib app django.contrib.staticfiles:

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

“Django现在希望在URL / admin /下找到admin静态文件,所以现在不推荐使用ADMIN_MEDIA_PREFIX - Apache设置中的别名就足够了,例如:

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

这适合我。