私の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エラーを解決するために期待しているURLですか?あなたのページのHTMLソースコードを見て、返されるものが正しいことを確認しましたか?どのようにDIrectory/Allowが行方不明ですか? –