Please help me to change the default schema from public to custom_schema. Also I am using the tenant to create the multiple tenants for the same base custom_schema tables.
Asked
Active
Viewed 1,448 times
1
-
You should check https://stackoverflow.com/questions/50819748/django-and-postgresql-schemas. It can be useful for your question – Giancarlo Ventura Jan 06 '22 at 04:29
-
Check this answer [Link](https://stackoverflow.com/a/28452103/1079086) – Akash senta Jan 06 '22 at 04:37
-
Thank for the help but it didn't work. – VRAJESH VAGHASIYA Jan 06 '22 at 05:55
1 Answers
2
if you want to use only one schema, it is enough that add options to db configuration in settings.py. You should create a new schema called 'custom_schema' before migration.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'OPTIONS': {
'options': '-c search_path=custom_schema'
},
'NAME': 'name',
'USER': 'user',
'PASSWORD': 'password',
}
}
If you want to use more than one schema, add a second db configuration to the db configuration with only the schema name different. Then write a router to decide which db will work in which situations.

koksal
- 161
- 4