Serving static files in django 1.8

296 views Asked by At

My 404.html page does not reference my finale.css file. My directory structure

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

This is where in index.html I'm referencing the css

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

But 404.html that extends index.htmlis not referencing the 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")

Both the index.htmland template.html are placed in the same folder and are properly referencing the css.Plus all the html pages in feature that are extending index.html are also referencing the css.But both 404.html and 500.htmlare not.

0

There are 0 answers