在django 1.8中提供静态文件

时间:2015-06-10 22:20:43

标签: python django django-templates

我的404.html页面未引用我的finale.css文件。 我的目录结构

musicworld/
   musicworld/
           __pycache__
           __int__.py
           settings.py
           urls.py
           wsgi.py
   feature/
           __pycache__
           migrations
           static/
                 feature/
                        finale.css
           templates/
                 feature/
                        about.html
                        detail.html
                 404.html
                 500.html
                 index.html
                 template.html
            __init__.py
            admin.py
            models.py
            tests

这是index.html我引用css的地方

    <link rel="stylesheet" type="text/css" href="{% static 'feature/finale.css' %}" />

但扩展404.html的{​​{1}}未引用css

index.html

{% extends "index.html" %} {% load staticfiles %} {% block 404page %} <div class="box"> <p class="box-message" data-dead-message="AAAAAHHHHHH!">Oh No! Something went wrong.Punish the developer by clicking here.</p> </div> <div class="robot"> <img src="" alt="Robot" /> </div> {% endblock %}

static reference in settings.py

STATIC_URL = '/static/' SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['*'] STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, "media") index.html都放在同一个文件夹中并且正确引用了css.Plus所有扩展template.html的功能中的html页面也是引用css.But index.html404.html都不是。

0 个答案:

没有答案