MEDIA_URLまたはSTATIC_URLを使用して/static/を指す場合、現在MEDIA_URLを/ static /に設定し、次のようなCSSファイルへのパスで使用します。
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/css.css" />
を指します/static/css.css
が、試行するとhttp://localhost/static/css.css
404エラーが発生します。
私は設定にあります:
.....
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/static/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = 'D:/programming/django_projects/ecomstore/'
.....
urls.pyには、次のような静的なポイントがあります。
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':'D:/programming/django_projects/ecomstore/'}
では、どこに問題があるのでしょうか。404が表示されるのはなぜですか?静的ファイルのビューを作成する必要がありますか?または、私の設定またはurls.pyに何か問題がありますか?私はdjangoの初心者なので、どんな回答でもいただければ幸いです。
前もって感謝します