I am developing a Django (1.3) project composed of many applications. Each application has its own static files under its own static
directory. Moreover, I have added a directory called project_static
which should contain static files which are common throughout the various applications, such as jQuery.
The problem I immediately run into is that of naming collisions. By default, collectstatic
will just put everything under a global static
directory, without classifying them by application. This does not work for me, as each application has - for instance - a file called css/screen.css
.
The way I solved it is by removing django.contrib.staticfiles.finders.AppDirectoriesFinder
from STATICFILES_FINDERS
and using namespaced static files dirs, so my settings now look like:
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, 'project_static'),
('my_app', os.path.join(PROJECT_PATH, 'my_app', 'static')),
('another_app', os.path.join(PROJECT_PATH, 'another_app', 'static')),
...
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
)
The problem is that in this way I lose the static files for all other applications (e.g. django.contrib.admin
). Of course I could manually add the admin, but I'm not sure how to do this without breaking the admin, which has a different directory structure.
Is there a better way to manage the static files with more than one application?