Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
README
======

Get the code via svn:
Get the code via git:

git clone git://github.com/shestera/django-multisite.git django-multisite

Expand Down
36 changes: 30 additions & 6 deletions multisite/template_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,39 @@
import os.path
from django.contrib.sites.models import Site
from django.conf import settings
from django.template.loaders.app_directories import *


def get_template_sources(template_name, template_dirs=None):
template_dir = os.path.join(settings.TEMPLATE_DIRS[0], Site.objects.get_current().domain)
try:
yield safe_join(template_dir, template_name)
except UnicodeDecodeError:
raise
except ValueError:
pass

if not template_dirs:

template_dirs = app_template_dirs
for template_dir in template_dirs:
try:
host = Site.objects.get_current().domain

# template directories shouldn't need to include port number
# so remove the port from the sites domain name for the search path.
try:
host = host.rsplit(":")[0]
except:
pass


template_dir = os.path.join(template_dir, host)
yield safe_join(template_dir, template_name)

except UnicodeDecodeError:
# The template dir name was a bytestring that wasn't valid UTF-8.
raise

except ValueError:
# The joined path was located outside of template_dir.

pass


def load_template_source(template_name, template_dirs=None):
tried = []
Expand Down