0

My base.html cannot find base.css. I configured my settings.py file to point to where the css file resides but still get 404.

I have the following at bottom of settings.py

STATIC_URL = '/static/'
STATICFILES_DIR = [os.path.join(BASE_DIR, 'static')]

File system tree:

.
├── blog
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── blog_project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── manage.py
├── Pipfile
├── Pipfile.lock
├── static
│   └── css
│       └── base.css
└── templates
    ├── base.html
    └── home.html

Thank you.

2
  • what is the value of DEBUG in your settings.py? Commented Jun 12, 2019 at 10:41
  • Thank you all for the responses. It worked when correcting the spelling from STATICFILES_DIR to STATICFILES_DIRS (plural). Commented Jun 12, 2019 at 11:45

2 Answers 2

1

try this

in settings.py

STATIC_ROOT = BASE_DIR + '/static/'

in urls.py

from django.conf import settings

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

hope it helps

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

Comments

1

You are missing STATIC_ROOT.

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

Comments

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.