6

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.

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • Read this carefully and check if you missed something: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development – Udi Jun 20 '11 at 13:54
  • 1
    It has been read multiple times. Here I have the finder `AppDirectoriesFinder` activated but `manage.py findstatic` doesn't not seem to search into apps/static directory – Pierre de LESPINAY Jun 23 '11 at 09:17

2 Answers2

3

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.

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
1

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

VGE
  • 4,171
  • 18
  • 17
  • I have intentionally put a syntax error somewhere and the dump seems to have the good values `STATIC_ROOT '/home/glide/Documents/django/cbox/static_files/'` and `STATICFILES_DIRS ('/home/glide/Documents/django/cbox/static/',)` (cbox is the name of the project) – Pierre de LESPINAY Jun 20 '11 at 12:53