Just as the title says, static files somehow are not loading up in my template. I've tried working on it and looking at similar StackOverflow questions but I can't find a solution. I tried debugging it using browser's dev tools.
I tried opening the CSS file from there but it just leads me to this error. This leads me to the conclusion that Django doesn't seem to find base.css
inside the static folder. I've already done manage.py collectstatic
so there shouldn't be a problem. Thanks!
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/static/static/base.css
'static\base.css' could not be found
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
settings.py
# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
template
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
edit: reverted back {% static 'static/base.css' %}
to {% static 'css/base.css' %}
Firstly, you have to correct the settings.py :
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
Then, lets say, you stored your css file in static/base.css
Now, write, {% static 'base.css' %}
because django by-default look up for your static files in your app so you dont have to include static path.