2👍
Here’s what worked in the end:
I wrote a new manage.py command that was a wrapper for the commands I wanted to be schema-aware (syncdb, migrate, changepassword), and select the schema manually by:
from django.db import connection
cursor = connection.cursor()
cursor.execute('SET search_path TO ' + my_little_schema)
4👍
You can assign a default schema to a database user or – to be precise – you assign a schema search path to a user. If that path only contains a single schema, you effectively set a default schema for the user.
Any unqualified object name (table, view, function, …) is then looked for along the path. Unqualified CREATE statements will create the object in the first schema of the search path.
So all you need to do is to change the user that Djange uses to connect to the database:
alter user django_user set search_path to the_one_schema;
commit;
After that, e.g. a create table foo
will create the table in the schema the_one_schema
.
You need to log off and then log on again to make the change “active”.
- [Django]-Django cannot find my templatetags, even though it's in INSTALLED_APPS and has a __init__.py
- [Django]-Can we create apps with twisted python as django…?
- [Django]-Django all-auth testing error – django.db.utils.OperationalError: no such table: socialaccount_openidstore
- [Django]-How to call multiple views on one url in pinax
- [Django]-Where should I place the one-time operation operation in the Django framework?