3

I am new to Django current version I'm running is 1.11 with python 3. I have configured the static file stuff as the docs suggest. Inside installed apps I have 'django.contrib.staticfiles'

nonprofit/nonprofit/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 be working as far as putting the right path in the template. Though even if I hardcode the path into the template the browser still gives a 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

From the browser it shows both 404 not found errors as well as not being able to go straight to the 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 right path, but even the hardcoded one cannot be accessed through the browser. I'm running the development server. Whats going on with this stuff? Do I have something wrongly configured or lacking configuration? Any help is appreciated. I have looked at all the suggested posts and have tried various things without any good results.

1 Answer 1

2

The setting name is STATICFILES_DIRS. You are missing the S.

Sign up to request clarification or add additional context in comments.

1 Comment

Man you are freaking awesome! I thought it had to be something stupid because I am very new to django. Thank you that works and fixes the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.