Note that there are some explanatory texts on larger screens.

plurals
  1. POManaging static files for multiple apps in Django
    primarykey
    data
    text
    <p>I am developing a Django (1.3) project composed of many applications. Each application has its own static files under its own <code>static</code> directory. Moreover, I have added a directory called <code>project_static</code> which should contain static files which are common throughout the various applications, such as jQuery.</p> <p>The problem I immediately run into is that of naming collisions. By default, <code>collectstatic</code> will just put everything under a global <code>static</code> directory, without classifying them by application. This does not work for me, as each application has - for instance - a file called <code>css/screen.css</code>.</p> <p>The way I solved it is by removing <code>django.contrib.staticfiles.finders.AppDirectoriesFinder</code> from <code>STATICFILES_FINDERS</code> and using <a href="https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#prefixes-optional" rel="nofollow noreferrer">namespaced static files dirs</a>, so my settings now look like:</p> <pre><code>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', ) </code></pre> <p>The problem is that in this way I lose the static files for all other applications (e.g. <code>django.contrib.admin</code>). 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.</p> <blockquote> <p>Is there a better way to manage the static files with more than one application?</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload