For some reason my static files are not loading:
My settings.py file:-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))
TEMPLATE_DIR=os.path.join(BASE_DIR,‘templates’)
STATIC_DIR=os.path.join(BASE_DIR,‘static’)
STATIC_ROOT=os.path.join(BASE_DIR,‘staticfiles’)
DEBUG=TRUE
In html file ,i have wriitten {%load static %}
I am using runserver to run django , my operating system is windows 10
No static files are found whether it is css or image file .
I have used collectstatic also ,but still not working
my html code
link rel="stylesheet" href="{% static 'css/demo.css'% }">
Please help in rectifying this problem
All the key information for getting started is on the Managing static files page. Please refer to that first if you have any questions. If anything’s unclear, we’ll work forward from that point.
What is the directory structure of your project? Where are the static files stored?
(If it makes it easier to follow and test, you can pick one file and we’ll walk through the issues - that should give you a pattern to follow for the rest.)
Do you have the staticfiles
app in your INSTALLED_APPS setting?
Couple notes:
- It’s DEBUG = True, not DEBUG = TRUE
- You have
"{% static 'css/demo.css'% }"
where it should be "{% static 'css/demo.css' %}"
(no space between the %
and closing brace).
I wouldn’t suggest retyping your code into the message if that’s what you’re doing. Errors tend to be introduced when people do it that way. Copy/paste from what ever editor you’re using directly into the post.
(Side note: when posting any code fragments or snippets, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then the lines of code, then another line of ```. A single line can be enclosed by a ` at the beginning and end of the code on that same line.)
Thank you ,it was the problem of space between the % and closing brace.