3

I have these settings in settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'

I've run collectstatic and there are files in /static/app/js directory:

jquery-3.2.1.min.c9f5aeeca3ad.js
jquery-3.2.1.min.js

I'm just using Django's runserver to test this at the moment.

If I run with DEBUG = True, everything works, as the JS is fetched from /static/app/js/jquery-3.2.1.min.js

If I run with DEBUG = False, all static files fail with 404. The JS URL is now /static/app/js/jquery-3.2.1.min.c9f5aeeca3ad.js

The URL looks correct, the files exist, what could be causing this to fail?

My view includes:

{% load static %}

<script src="{% static 'app/js/jquery-3.2.1.min.js' %}"></script>

Am I missing a setting?

(using Django 1.11, Python 3.6)

user3592246
  • 157
  • 2
  • 16
  • 1
    This only seems to be a problem with Django runserver, if I deploy the code to the server running Nginx/Gunicorn, the hashed files are served correctly. Is it just not possible using runserver? – user3592246 Jul 02 '17 at 12:30
  • 1
    Take a look at the answers in this SO question: https://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail – saschwarz Nov 19 '17 at 18:42

0 Answers0