Assuming I have a schema with the name "my_schema", how can I create tables with "django syncdb" for that particular schema? Or is there any other alternatives for quickly creating tables from my django models? I think, by default django creates tables for the "public" schema.
API schemas are a useful tool that allow for a range of use cases, including generating reference documentation, or driving dynamic client libraries that can interact with your API. Django REST Framework provides support for automatic generation of OpenAPI schemas.
Django's inspectdb feature uses the information_schema database, which contains detailed data on all database schemas.
First, you must have psycopg2>=2.4.3 [1]. If you have then you can add schema to OPTIONS in dictionary-based database configuration, like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
# ...
'OPTIONS': {
'options': '-c search_path=my_schema'
}
}
}
Tested on postgresql 8.4 and django 1.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With