So I am using django tenant with django rest framework. I have two created apps users and students. For users I was able to setup the model, serializer and viewset and create users using the viewset with no issues. Mirrored most of the logic for creating users in students but been having issues creating a student using the API. Keep getting the error Exception: Can't create tenant outside the public schema. Current schema is concord.
I have tried finding a similar issue on stack overflow but not seen anything similar. Would appreciate any help. Find relevant snippets below
# MIDDLEWARE
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [
"django_tenants.middleware.main.TenantMainMiddleware",
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.common.BrokenLinkEmailsMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
# ------------------------------------------------------------------------------
SHARED_APPS = (
"django_tenants", # mandatory
"dew_school_management_system.school",
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
# "django.contrib.humanize", # Handy template tags
"django.contrib.admin",
"django.forms",
"django_filters",
"dew_school_management_system.users",
"crispy_forms",
"crispy_bootstrap5",
"allauth",
"allauth.account",
"allauth.socialaccount",
"django_celery_beat",
"rest_framework",
"rest_framework.authtoken",
"dj_rest_auth",
"corsheaders",
"drf_spectacular",
)
TENANT_APPS = (
"django.contrib.auth",
"django.contrib.sessions",
"dew_school_management_system.users",
"dew_school_management_system.students",
# Your stuff: custom apps go here
)
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = list(SHARED_APPS) + [
app for app in TENANT_APPS if app not in SHARED_APPS
]
# TENANT CONFIGURATION
TENANT_MODEL = "school.School"
TENANT_DOMAIN_MODEL = "school.SchoolDomain"
I have tried finding a similar issue here but not seen anything similar,