Reputation: 48
I am aware that similar question was answered in Django - Static file not found But looks like I miss something or it was, somehow, a different case.
I have my static folders set in settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static/")
]
And in the code, I refer to file like
{% load staticfiles %}
<link href="{% static 'filename.css' %}" rel="stylesheet">
Still, django searches for this file in /view/filename.css
How do I make it work?
P.S. Also bootstrap.css
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="hash" crossorigin="anonymous">
isn't loaded for the same reason.
Upvotes: 1
Views: 823
Reputation: 1774
A path to 'static' folder, if you create project like this: django-admin startproject myproject_root, should be: "myproject_root/myproject/static"
# settings.py
DEBUG=True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'myproject/static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'myproject/'),
]
Upvotes: 1
Reputation: 156
Do you have django.contrib.staticfiles included in your INSTALLED_APPS ? What django version are you using? If you just debug your app, you must set setting DEBUG=True to allow django serve your static files.
Upvotes: 1