From 201abff2c270165f29bc8e08aef63f4999e81567 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Fri, 30 May 2014 17:08:08 +0200 Subject: [PATCH 1/2] context processor for appending tenant name in static url --- entrouvert/djommon/multitenant/context_processors.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 entrouvert/djommon/multitenant/context_processors.py diff --git a/entrouvert/djommon/multitenant/context_processors.py b/entrouvert/djommon/multitenant/context_processors.py new file mode 100644 index 0000000..3ccf3b3 --- /dev/null +++ b/entrouvert/djommon/multitenant/context_processors.py @@ -0,0 +1,14 @@ +from django.conf import settings +from tenant_schemas.utils import remove_www_and_dev + +def static(request): + """ + Add tenant dependend static context variable to the context + """ + try: + static_url = settings.STATIC_URL + except AttributeError: + raise ImproperlyConfigured('STATIC_URL must be defined') + + return {'STATIC_URL': '%s/%s' % (static_url, + remove_www_and_dev(request.get_host().split(':')[0]))} -- 2.0.0