我的css文件不在Production server
中工作。我部署使用WSGI
。你能解決我的問題嗎?謝謝 css link
CSS文件沒有出現在生產服務器
<link href="{{ MEDIA_URL}}css/style.css" rel="stylesheet" type="text/css" />
settings.py
CURRENT_PATH = '/home/nibbler/code/project/
MEDIA_ROOT = os.path.join(CURRENT_PATH, 'templates/media')
MEDIA_URL = '/media/'
TEMPLATE_DIRS = (
os.path.join(CURRENT_PATH, 'templates/temp_name'),
)
site-available\default
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName project.org
DocumentRoot "/home/nibbler/code/project/"
ServerName localhost
ErrorLog "/home/nibbler/code/project/logs/apache-error.log"
CustomLog "/home/nibbler/code/project/logs/apache-access.log" common
Options ExecCGI FollowSymLinks MultiViews
AddHandler wsgi-script .wsgi
WSGIDaemonProcess nibbler
WSGIProcessGroup nibbler
Alias /media /home/nibbler/code/project/templates/media/
WSGIScriptAlias//home/nibbler/code/project/apache/django.wsgi
DirectoryIndex index.html index.cgi
AddHandler cgi-script .cgi .pl
</VirtualHost>
urls.py
if settings.DEBUG:
# static files (images, css, javascript, etc.)
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}))
MEDIA_ROOT相同。 settings.py中沒有結尾的斜槓。 –
@Graham Dumpleton Ive變了。但不工作。 – Kulbir
您是否嘗試過訪問靜態媒體文件?您是否希望他們能夠計算出哪些HTTP錯誤?您是否查看過網頁的HTML源代碼以查看返回的內容是否正確? DIrectory/Allow如何丟失? –