Reputation: 11021
I have my project laid out like this: Project App1 App2
My static folder is in Project with 2 directories like so: -/Project/static/css -/Project/static/js
I have the following config in my settings.py file:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
...
urlpatterns += staticfiles_urlpatterns()
However I am getting 404s on any files served from there. I have 'django.contrib.staticfiles', in my INSTALLED_APPS constant and my static constants set like:
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
MEDIA_ROOT = PROJECT_PATH + '/media/'
MEDIA_URL = '/media'
STATIC_ROOT = PROJECT_PATH + '/static/'
STATIC_URL = '/static'
What could I be doing wrong? I get nothing but 404s and it is driving me crazy.
Upvotes: 3
Views: 337
Reputation: 11021
I was setting STATIC_ROOT and MEDIA_ROOT when I should have been setting this:
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
PROJECT_PATH + '/static/',
)
Upvotes: 4