Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Static Files from App Directories

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.

like image 572
Pierre de LESPINAY Avatar asked Jun 20 '11 10:06

Pierre de LESPINAY


2 Answers

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.

like image 167
Pierre de LESPINAY Avatar answered Sep 22 '22 17:09

Pierre de LESPINAY


Check the value of STATIC_ROOT and STATICFILES_DIRS. Add a print in your setting file.

like image 21
VGE Avatar answered Sep 18 '22 17:09

VGE