我正在尝试使用 mod_wsgi 和 Apache2 部署我的 Django 项目,但我无法弄清楚为什么没有加载管理 CSS 样式。我已经使用 Django-admin-tools 作为应用程序来增强管理界面的外观,并且它在开发服务器上运行良好,但是在部署过程中出现了样式问题。
服务器上的项目路径是:
'/srv/www/myapp/'
'/srv/www/myapp/media/admin_tools/css|js|images'
setting.py 包含:
MEDIA_ROOT = '/srv/www/myapp/media/'
# also tried MEDIA_ROOT = '/srv/www/myapp/media/admin_tools/'
MEDIA_URL = 'http://myserverip:80/media/'
STATIC_ROOT = '/srv/www/myapp/static'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
# also tried ADMIN_MEDIA_PREFIX = '/media/admin_tools/'
STATICFILES_DIRS = (
'/srv/www/myapp/projectstatic' )
TEMPLATE_DIRS = (
'/srv/www/myapp/templates' )
INSTALLED_APPS = (
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
#Many other applications )
ADMIN_TOOLS_INDEX_DASHBOARD = 'myapp.dashboard.CustomIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'myapp.dashboard.CustomAppIndexDashboard'
ADMIN_TOOLS_THEMING_CSS = '/srv/www/myapp/media/admin_tools/css/theming.css'
ADMIN_TOOLS_MENU = 'myapp.menu.CustomMenu'
网址.py:
urlpatterns = patterns('',
url(r'^admin_tools/', include('admin_tools.urls')),
)
django.wsgi: (这个文件的路径是'/srv/www/myapp/apache/django.wsgi')
import os
import sys
path = '/srv/www/'
if path not in sys.path:
sys.path.insert(0, '/srv/www/')
sys.path = ['/srv/www/myapp'] + sys.path
sys.path.append('/usr/local/lib/python2.7/dist-packages/registration/backends')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
print >> sys.stderr, sys.path
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()