I have a really weird situation I cannot seem to figure out. I have not touched my implementation of this package since the beginning of the year and now the functionality ceases to exist on my live heroku server. I currently have a Create Account form on my public tenant which generates a tenant/domain just as the docs do and django-tenants does its auto schema generation. This works correctly on my localhost and have zero problems. However on my live server, I proceed to get a 404 error... Not Found...The requested URL / was not found on this server.
I have a CNAME
record on DNSimple which points to a wildcard domain that appears to be working, because I have already have a tenant I made awhile ago that is still completely functional (ie. some-customer.mydomain.com
). I have looked into my PSQL db attached to heroku and everything is there as it should be, as well as the migrations occurring in the logs when I create an account which generates a tenant.
I was hoping that there might be some enlightenment as to what I am doing/have done wrong to make this issue occur. It just seems so odd that none of my now generated tenants can be accessed via their Domain
.
Edit: Posting Code.
local .env file
SECRET_KEY=...
DEBUG=True
DB_NAME=...
DB_USER=...
DB_PASSWORD=...
DB_HOST=localhost
ALLOWED_HOSTS=.localhost, .herokuapp.com
GOOGLE_RECAPTCHA_SECRET_KEY=...
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_STORAGE_BUCKET_NAME=...
SECURE_SSL_REDIRECT='False'
settings.py (included things I think are relative)
...
LOGIN_URL = 'login'
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv())
DEBUG = config('DEBUG', default=False, cast=bool)
SECRET_KEY = config('SECRET_KEY')
SHARED_APPS = (
'django_tenants',
'tenant',
'django.contrib.contenttypes',
'public.apps.PublicConfig',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'debug_toolbar',
'storages'
)
TENANT_APPS = (
'django.contrib.contenttypes',
'inventory.apps.InventoryConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
)
INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]
TENANT_MODEL = 'tenant.Client'
TENANT_DOMAIN_MODEL = 'tenant.Domain'
MIDDLEWARE = [
'django_tenants.middleware.main.TenantMainMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'myapp.urls'
WSGI_APPLICATION = 'myapp.wsgi.application'
DATABASE_ROUTERS = (
'django_tenants.routers.TenantSyncRouter',
)
PUBLIC_SCHEMA_URLCONF = 'myapp.urls_public'
SECURE_SSL_REDIRECT = config('SECURE_SSL_REDIRECT', default=False, cast=bool)
...
production Heroku settings (included relative stuff)
...
ALLOWED_HOSTS: .herokuapp.com, .mydomain.com, mydomain.com
DEBUG: False
SECURE_SSL_REDIRECT: True
...
urls.py (each tenant should see these)
urlpatterns = [
...
url(r'^$', dashboard, name='dashboard'),
url(r'^login/$', login_view, name='login'),
url(r'^logout/$', logout_view, name='logout'),
...
]
urls_public.py (main site)
urlpatterns = [
url(r'^$', home_view, name='home'),
url(r'^login/$', login_view, name='login'),
url(r'^logout/$', logout_view, name='logout'),
url(r'^create_account/$', create_account_view, name='create_account'),
]