Reputation: 69
I have created a /static/ folder in my project's root and changed the settings thusly:
STATIC_URL = '/static/'
STATICFILES_DIR = [os.path.join(BASE_DIR, "static")]
But when I open my localhost/static, it produces a 404 error. Why is that?
Upvotes: 0
Views: 71
Reputation: 363
For Django 1.3+:
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
]
STATIC_ROOT = path.join(TOP_DIR, 'staticfiles')
STATIC_URL = '/static/'
For apache:
Alias /static /var/my/site/static
<Directory /var/my/site/static>
Require all granted
</Directory>
Upvotes: 2
Reputation: 296
Are you aiming at a particular file? If not then theres your problem, if you are aiming at a file, are you sure its in the correct directory?
Upvotes: 1
Reputation: 2424
You have to run manage.py collectstatic
first.
Note: It's also possible that going to /static
is the cause (missing the trailing slash) though django should redirect.
Upvotes: 0