Reputation: 11
I want to save my style.css file in the main project folder (for my project in django that is) under either /static/ or /templates/ but I cannot seem to load it properly. I use:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static '/style.css' %}" \>
This css file is suppose to be loaded with my /templates/base.html site (stored in the main project folder).
Thanks, Matt
Upvotes: 1
Views: 33
Reputation: 45575
Loading of static files from templates
directory is a bad idea - source of your templates will be available to web user.
To load files from static/
directory add the STATICFILES_DIRS
to your settings.py
:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
And BTW remove the first slash in the {% static %}
tag:
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" \>
Upvotes: 1