I can't get my static files to come up. I've tried various settings and directory configurations and so on, but they just turn up as 404s. I have debug_toolbar installed so know that STATIC_URL is reaching my request context.
Directory structure showing /static (I have also placed the directory inside of the meals app folder, and users, just to try it out.
/mealmate
/mealmate
/meals
/static
/css
/bootstrap.min.css
/templates
/users
Settings.py (a few important settings though I've experimented with a variety of other ones):
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media/')
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
)
WSGI_APPLICATION = 'mealmate.wsgi.application'
In base.html rendered
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
Any ideas? Thanks
I'm assuming you're using Django1.3+ here.
First off, you need to define a few more settings:
This should help you find that directory.
Also, you should always access your static files using
STATIC URL
:Make sure mealmate is in your INSTALLED_APPS
I was also stuck in the 404 problem until I realized that Apache had blocked the requests to the static dir. I used
python manage.py collectstatic
to copy all the static files to the static dir under my project root, i.e. /var/my/site/static. Within /etc/httpd/conf/httpd.conf, it works properly now.
If none of the answers above works, you may consider checking your server config.