1

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.

2 Answers2

1

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.

1

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/'),
]
Alexandr S.
  • 1,607
  • 1
  • 14
  • 16
  • Thanks for the advice, but unfortunately it didn't work. – Artem Slepentsev Jan 05 '19 at 10:58
  • Hi, it must work, if you haven't solved this problem yet, post here structure of your project directory with "static" folder and part of settings.py file with paths to the static folder and I'll try to help you. – Alexandr S. Jan 06 '19 at 00:55