I’m trying to render static files locally in development. I have followed the rules and placed stylesheets in /static/ in my Django project folder, setting STATIC_URL = '/static/'. Using the {{ STATIC_URL }} template tag works and the paths rendered in the document head point to the correct directory (as far as I can tell), e.g.:
http://localhost:8000/static/css/bootstrap.min.css
This returns a 404, and of course, there’s no styling.
I started with /static and its contents (i.e. /css/bootstrap.min.css) in the project root folder. I then copied it and its entire contents to all the other app directories, to try different places Django might be looking. Still 404.
Relevant settings in settings.py:
DEBUG = True
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'south',
'users',
'registration',
'django_extensions',
'django.contrib.admin',
)
What’s going wrong?
Matt
What does your
urls.pylook like? Have you forgotten to include a static files url? If you look at the documentation on serving static files https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development it suggests putting the following inurls.py