Django - Static Files from App Directories

Pierre de LESPINAY picture Pierre de LESPINAY · Jun 20, 2011 · Viewed 8.3k times · Source

In a development environment, I'd like to use static files from the app directories.

#settings.py

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATIC_ROOT = (os.path.join(SITE_ROOT, 'static_files/'))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)
STATICFILES_FINDERS = (
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = (
#...
  'django.core.context_processors.static',
#...
)
INSTALLED_APPS = (
#...
  'django.contrib.staticfiles',
#...
)

I can find my static file if located in /static/css/file.css but not if in an_app/static/css/file.css.

Answer

Pierre de LESPINAY picture Pierre de LESPINAY · Jul 13, 2011

Ok I found the problem, I made an oversight that was not visible in my question. I was searching into in static/js, static/flash, static/css, static/images and put the files directly into app/static so they were not found.