I have a django project for which suddenly (after updating PyCharm) the staticfiles can't be loaded anymore. This is the project structure:
├── _quanttool
│ ├── _quanttool
│ │ ├── __init__.py
│ │ ├── asgi.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── _static
│ │ ├── css
│ │ ├── img
│ │ ├── js
│ │ ├── scss
│ │ └── vendor
│ ├── _templates
│ │ ├── base
│ │ ├── funds_tool
│ │ └── transaction_list
│ ├── funds_tool
.
.
.
│ ├── db.sqlite3
│ └── manage.py
├── venv
├── .gitignore
└── README.md
In the settings.py file i have configured:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/_static/'
STATIC_ROOT = '_static'
STATICFILES_LOCATION = [os.path.join(BASE_DIR, '_static')]
In the base HTML Template I have set {% load static %}
and <link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
I really don't understand why I suddenly get the errors: "GET /_static/css/sb-admin-2.css HTTP/1.1" 404 1682" ...
Any idea why Django can't find the staticfiles anymore?
Best
comment out STATIC_ROOT = '_static'
and add the below code to your settings.py file.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/_static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, '_static'),)
If still not work then run this command on terminal
$ python manage.py collectstatic