Hello again,
I could use some help on loading static files in development mode. Specifically, I'd like to tell Django to serve additional files that are not explicitly loaded in the html with {% load static %}. My issue is actually identical to
this post, where I could use some extra explanation on their suggested fix. To restate the issue, I load a static javascript file within my myapp/index.html:
{% load static %}
<script src="{% static 'myapp/myscript_1.js' %}"></script>
The javascript file (myscript_1.js) references another javascript file (myscript_2.js) as well as some other media (e.g. a number of *.png, *.css, *.json files). However, Django doesn't serve these files because they are not directly loaded in the html, and a 404 error is thrown when trying to find myscript_2.js - along with the other files. How do I get Django to serve these files as well?
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(path=settings.STATIC_URL, document_root=settings.STATIC_ROOT)
and in my settings.py:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = /static/
This isn't working for me though, and I think I'm using the static() function incorrectly. Could someone offer some guidance on how to set this up for development testing?
Thanks in advance,
Jack