I am trying to get tenants to have custom templates to be rendered. I am struggling to achieve this using django tenants. I have been following the documentations here: Tenant-aware file handling — django_tenants dev documentation. I have noticed that django-tenant does not come with a template loader like django-tenant-schemas.
Here is what my project tree roughly looks like:
myapp
├── customers
│ ├── __pycache__
│ ├── migrations
│ │ └── __pycache__
│ └── templates
│ ├── landpage
│ │ ├── contactform
│ │ │ └── img
│ │ ├── css
│ │ ├── fonts
│ │ └── js
│ └── registration
├── dashboard2
│ ├── __pycache__
│ ├── migrations
│ │ └── __pycache__
│ ├── migrations2
│ │ └── __pycache__
│ ├── templates
│ │ └── dashboard2
│ │ └── pdf
│ └── tenants
│ ├── itoiz
│ │ └── templates
│ └── test
│ └── templates
├── inventory4
│ └── __pycache__
├── locale
│ └── fr
│ └── LC_MESSAGES
├── logs
├── mediafiles
│ └── tenants
│ └── t5
│ └── api
│ ├── historical
│ └── preprocessing
├── static
│ ├── admin
│ │ ├── css
│ │ │ └── vendor
│ │ │ └── select2
│ │ ├── fonts
│ │ ├── img
│ │ │ └── gis
│ │ └── js
│ │ ├── admin
│ │ └── vendor
│ │ ├── jquery
│ │ ├── select2
│ │ │ └── i18n
│ │ └── xregexp
│ ├── css
│ ├── css2
│ ├── css3
│ ├── django_tables2
│ │ └── themes
│ │ └── paleblue
│ │ ├── css
│ │ └── img
│ ├── fonts
│ ├── fonts2
│ ├── icons-reference
│ │ └── fonts
│ ├── img
│ │ ├── flags
│ │ │ └── 16
│ │ └── photos
│ ├── js
│ ├── rest_framework
│ │ ├── css
│ │ ├── docs
│ │ │ ├── css
│ │ │ ├── img
│ │ │ └── js
│ │ ├── fonts
│ │ ├── img
│ │ └── js
│ └── vendor
│ ├── bootstrap
│ │ ├── css
│ │ └── js
│ ├── chart.js
│ ├── font-awesome
│ │ ├── css
│ │ └── fonts
│ ├── jquery
│ ├── jquery-validation
│ │ └── localization
│ ├── jquery.cookie
│ └── popper.js
│ ├── esm
│ └── umd
├── staticfiles
│ ├── admin
│ │ ├── css
│ │ │ └── vendor
│ │ │ └── select2
│ │ ├── fonts
│ │ ├── img
│ │ │ └── gis
│ │ └── js
│ │ ├── admin
│ │ └── vendor
│ │ ├── jquery
│ │ ├── select2
│ │ │ └── i18n
│ │ └── xregexp
│ ├── css
│ ├── css2
│ ├── css3
│ ├── django_tables2
│ │ └── themes
│ │ └── paleblue
│ │ ├── css
│ │ └── img
│ ├── fonts
│ ├── fonts2
│ ├── icons-reference
│ │ └── fonts
│ ├── img
│ │ └── flags
│ │ └── 16
│ ├── js
│ ├── rest_framework
│ │ ├── css
│ │ ├── docs
│ │ │ ├── css
│ │ │ ├── img
│ │ │ └── js
│ │ ├── fonts
│ │ ├── img
│ │ └── js
│ └── vendor
│ ├── bootstrap
│ │ ├── css
│ │ └── js
│ ├── chart.js
│ ├── font-awesome
│ │ ├── css
│ │ └── fonts
│ ├── jquery
│ ├── jquery-validation
│ │ └── localization
│ ├── jquery.cookie
│ └── popper.js
│ ├── esm
│ └── umd
├── tenantlogin
│ ├── __pycache__
│ ├── migrations
│ │ └── __pycache__
│ └── templates
│ └── registration
└── uploadfiles
├── __pycache__
├── migrations
│ └── __pycache__
└── templates
for each tenant, I want to override the templates in dashboard2/templates
with the templates located in the tenant folder in dashboard2
.
I have set up my settings.py file as such to handle the tenant file handling system:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,"dashboard2/templates/dashboard2")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n'
],
},
},
]
STATIC_URL = '/static/'
STATICFILES_FINDERS = [
"django_tenants.staticfiles.finders.TenantFileSystemFinder", # Must be first
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"compressor.finders.CompressorFinder",
]
MULTITENANT_STATICFILES_DIRS = [
os.path.join( "myapp/dashboard2/", "tenants/%s/static" ),
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'staticfiles')
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MULTITENANT_RELATIVE_STATIC_ROOT = "tenants/%s
MEDIA_URL = '/mediafiles/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles')
TENANT_MODEL = "customers.Client"
TENANT_DOMAIN_MODEL = "customers.Domain"
DEFAULT_FILE_STORAGE = "django_tenants.files.storage.TenantFileSystemStorage"
MULTITENANT_RELATIVE_MEDIA_ROOT = "tenants/%s"
Unfortunately, this does not work, and I am not sure what to do to make it work. Any help would be appreciated.