Skip to content

Instantly share code, notes, and snippets.

@bruth
Created November 1, 2011 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruth/1331232 to your computer and use it in GitHub Desktop.
Save bruth/1331232 to your computer and use it in GitHub Desktop.
Django staticfiles storage and finder classes for apps to copy static files into their own directory
# Add:
#
# STATICFILES_FINDERS = (
# 'path.to.this.module.PrefixedAppDirectoriesFinder',
# ...
# )
from django.contrib.staticfiles.finders import AppDirectoriesFinder
from django.contrib.staticfiles.storage import AppStaticStorage
class PrefixedAppStaticStorage(AppStaticStorage):
def __init__(self, app, *args, **kwargs):
self.prefix = app
super(PrefixedAppStaticStorage, self).__init__(app, *args, **kwargs)
class PrefixedAppDirectoriesFinder(AppDirectoriesFinder):
storage_class = PrefixedAppStaticStorage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment