From 94667818226ef5709010bece5c40a70ad3facb3d Mon Sep 17 00:00:00 2001 From: Juan Marquez Date: Sun, 7 May 2017 13:00:49 -0400 Subject: [PATCH 1/2] Compatibility with Django 1.11 LTS (Tutorial) #477 -------------------------------------------------- Update tenant_tutorial to Django 1.11 To create a PR --- .../tenant_tutorial/settings.py | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/examples/tenant_tutorial/tenant_tutorial/settings.py b/examples/tenant_tutorial/tenant_tutorial/settings.py index 0a3d190..bb78a91 100644 --- a/examples/tenant_tutorial/tenant_tutorial/settings.py +++ b/examples/tenant_tutorial/tenant_tutorial/settings.py @@ -1,9 +1,9 @@ import os +from collections import OrderedDict # Django settings for tenant_tutorial project. DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), @@ -24,7 +24,7 @@ DATABASES = { # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['localhost', '.trendy-sass.com'] # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -85,11 +85,6 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = 'as-%*_93v=r5*p_7cu8-%o6b&x^g+q$#*e*fl)k)x0-t=%q0qa' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) DATABASE_ROUTERS = ( 'tenant_schemas.routers.TenantSyncRouter', @@ -108,22 +103,37 @@ MIDDLEWARE_CLASSES = ( # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.core.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.media', - 'django.core.context_processors.static', - 'django.contrib.messages.context_processors.messages', -) - ROOT_URLCONF = 'tenant_tutorial.urls_tenants' PUBLIC_SCHEMA_URLCONF = 'tenant_tutorial.urls_public' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'tenant_tutorial.wsgi.application' -TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/'),) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/'), + ], + 'APP_DIRS': False, + 'OPTIONS': { + 'debug': DEBUG, + 'context_processors': [ + # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this + #~ 'django.core.context_processors.request', + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + # List of callables that know how to import templates from various sources. + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', # insert your TEMPLATE_LOADERS here + ] + }, + }, +] SHARED_APPS = ( 'tenant_schemas', # mandatory @@ -144,7 +154,9 @@ TENANT_APPS = ( TENANT_MODEL = "customers.Client" # app.Model -INSTALLED_APPS = list(set(TENANT_APPS + SHARED_APPS)) +DEFAULT_FILE_STORAGE = 'tenant_schemas.storage.TenantFileSystemStorage' + +INSTALLED_APPS = list(OrderedDict.fromkeys(SHARED_APPS + TENANT_APPS)) SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' From 510e0f90151b75e70e6c624152fcfa43c1384262 Mon Sep 17 00:00:00 2001 From: Gary Reynolds Date: Fri, 2 Jun 2017 18:40:03 +1000 Subject: [PATCH 2/2] Explicitly define INSTALLED_APPS in settings.py --- examples/tenant_tutorial/tenant_tutorial/settings.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/tenant_tutorial/tenant_tutorial/settings.py b/examples/tenant_tutorial/tenant_tutorial/settings.py index bb78a91..0f4001c 100644 --- a/examples/tenant_tutorial/tenant_tutorial/settings.py +++ b/examples/tenant_tutorial/tenant_tutorial/settings.py @@ -156,7 +156,15 @@ TENANT_MODEL = "customers.Client" # app.Model DEFAULT_FILE_STORAGE = 'tenant_schemas.storage.TenantFileSystemStorage' -INSTALLED_APPS = list(OrderedDict.fromkeys(SHARED_APPS + TENANT_APPS)) +INSTALLED_APPS = ( + 'tenant_schemas', + 'customers', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +) SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'