Skip to content

Instantly share code, notes, and snippets.

@toudi
Created March 27, 2013 09:54
Show Gist options
  • Save toudi/5253106 to your computer and use it in GitHub Desktop.
Save toudi/5253106 to your computer and use it in GitHub Desktop.
staticfiles finder which allows you to use STATIC_ROOT for hosting static files on development server
from django.contrib.staticfiles.finders import DefaultStorageFinder
from django.conf import settings
from django.core.files.storage import FileSystemStorage
class StaticRootFinder(DefaultStorageFinder):
def __init__(self, *args, **kwargs):
self.storage = FileSystemStorage(location=settings.STATIC_ROOT, base_url=settings.STATIC_URL)
super(StaticRootFinder, self).__init__(*args, **kwargs)
# settings.py:
# STATICFILES_FINDERS = (
# 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'path.to.finders.StaticRootFinder'
# )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment