I am brand new to django, and I am working on setting up the basics of my first project and first app. I migrated my models to SQL Server, and all of the tables showed up under the schema dbo (default schema). I followed the direction of another SO question and set my default schema from within SQL Server to the schema of my choice. I deleted my migration history and migrated again from django. All the tables were created in the dbo schema again.
I see that I can set db_table
in the Meta class of Models. However, I also am seeing on other questions that specifying a schema here doesn't always allow for migration changes, writes, etc.
Is it possible to set the schema for django to use?
Edit: I tried specifying a schema with this db_table = 'myschema\".\"mytable'
. This resulted in django just creating the model as dbo.myschema.mytable
.
I'm also seeing that set_search_path
is an option for some databases, but it is not an option for SQL Server.
Use the following for MSSQL:
db_table = '[schemaname].[tablename]'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.