I have a project-level directory named static
which contains various .css, images, and javascript files. My settings file contains:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
DEBUG = True
...
INSTALLED_APPS = [
...
'django.contrib.staticfiles',
]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/static/' # I've tried with and w/o this
STATICFILE_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
My urls.py
file contains:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
I've printed out BASE_DIR
and it points to the correct directory. Yet, when I load my webpage, I receive this error:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/static/css/style.css
This file exists, and it exists in exactly the location that Django is trying to access. Still, these files aren't found. I'm a bit at my wits end—the documentation has no information outside of what I've already done, and I've searched around for hours. All of the already-answered questions here regard STATICFILE_DIRS
. This question, for example, points out that—when DEBUG = True
—one doesn't have to run collectstatic
and using STATICFILE_DIRS
should suffice.
Edit: GOD DAMNIT. It's STATICFILES_DIRS
and not STATICFILE_DIRS
. That was my problem. -_-