Django static files don't resolve persistent 404 errors
I am new to the current version of Django. I am running 1.11 with python 3. I set up a static file as the docs suggest. Inside installed apps, I have'django.contrib.staticfiles'
Non-commercial / non-commercial / settings.py
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATICFILES_DIR = (
os.path.join(BASE_DIR, "static/"),
)
And django seems to work before putting the correct path into the template. Although even if I hardcode the path to the template, the browser still gives 404 not found.
I have a base.html template with some css.
{% load staticfiles %}
<!--Bootstrap-->
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
<link rel="stylesheet" href="/static/css/bootstrap-theme.css">
My directory structure is -
nonprofit
- goals
- nonprofit
- static
- css
bootstrap.css
bootstrap-theme.css
- templates
base.html
db.sqlite3
manage.py
The browser displays both 404 not found errors and the impossibility of direct access to files.
GET http://127.0.0.1:8000/static/css/bootstrap.css 127.0.0.1/:19
GET http://127.0.0.1:8000/static/css/bootstrap-theme.css 127.0.0.1/:20
I don't think the problem is with django because it shows the correct path, but even the hard drive cannot be accessed through the browser. I am starting a development server. What's going on with this? Am I misconfigured or missing a configuration? Any help is appreciated. I have looked through all the posts suggested and tried different things without any good results.
source to share