1

Is it OK to set the database name setting depending on subdomain for each request?

Something like this in a middleware:

from django.db import connection

company_name = ... # read the subdomain
connection.settings_dict['NAME'] = 'db_' + company_name
1
  • This is not going to work like this. Commented Aug 6, 2012 at 1:31

1 Answer 1

1

I think it is not OK.

Are you trying to make a multi-tenant application? Look at this question:

See also the sites framework and multiple databases (specially routers, "Manually selecting a database" and "Exposing multiple databases in Django's admin interface".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.