在Django1.8中提供静态文件

2024-09-28 19:04:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我的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的地方

^{pr2}$

但是扩展index.html404.html没有引用css

{% 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.Plusfeature中扩展index.html的所有html页也在引用css。但是404.html和{}都不是。在


Tags: pydivboxmessageindexsettingshtmlstatic