How to override Django's internal use of "public" schema

I’ve searched all over for an answer to this issue, and can’t quite find the use-case I’m looking for.

There are many libraries and configuration styles people use in order to add Postgres schema support to Django. Some of these solutions require changing model code to explicitly set their schemas, and some of them even have you specify the schema for models when performing queries.

My use-case is, what I thought, something that would be much simpler and much easier to configure.

My intention is to build my Django app entirely inside a single custom schema of a larger Postgres database. So this includes django’s internal tables such as “auth_user”, “django_session”, etc. etc.

However, if I try to add

OPTIONS': { 'options': '-c search_path=custom_schema_name' },

to my ‘default' configuration, it doesn’t stop Django from populating the public schema for those default tables like auth_user, django_session, etc. When I perform python manage.py migrate and check the DB, the new tables get put into public.

Is there a way to completely override how Django connects to the database so that all of its operations swap to a single custom schema, both for all project-level models and also the internal framework models on project startup?

Welcome @rythazhur !

I suggest you see the thread at Why won't Django look for my Postgres schema?! .

In a standard / local PostgreSQL environment, it does work. However, the person asking the question in that topic identified that it was something in their hosting provider causing it to fail.