Skip to content

Instantly share code, notes, and snippets.

@beratdogan
Created February 20, 2016 20:28
Show Gist options
  • Save beratdogan/e5bb056a7515ecf9d0c2 to your computer and use it in GitHub Desktop.
Save beratdogan/e5bb056a7515ecf9d0c2 to your computer and use it in GitHub Desktop.
import os
from functools import partial
from django.contrib.sites.models import Site
from django.template.loaders.filesystem import Loader as FilesystemLoader
class SiteDirsLoader(FilesystemLoader):
def get_dirs(self):
templates_dir = super(SiteDirsLoader, self).get_dirs()[0]
appendr = partial(os.path.join, templates_dir)
domains = Site.objects.values_list('domain', flat=True)
dirs = map(appendr, domains)
return [appendr('default')] + dirs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment