here is my settings.py:
STATIC_DIR = os.path.join(BASE_DIR,'static')
STATIC_URL = '/static/'
STATICFILES_DIR = [STATIC_DIR]
here is the end of my html page:
{% load static %}
<script src="{% static '/js/script.js' %}" type="text/javascript"></script>
</html>
{% endblock %}
I have a folder static
and inside it, there are two more folders one is js
and the other is css
. But when I try to load it, it always says "GET /static/js/script.js HTTP/1.1" 404 1795
I have tried many things but it does not work. Someone please help.
CodePudding user response:
If it is development server (i.e DEBUG = True), then try this:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'static',
)
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
If it is production server, then you simply remove the STATICFILES_DIR
. The official documentation explains this more in depth.