django-tenant-schemas
django-tenant-schemas copied to clipboard
Avoiding hard-coding the domain in `domain_url`
Hi all! My tenants table looks like this -
| name | schema_name | domain_url |
|----------|-------------|-------------------|
| Tenant 1 | tenant1 | tenant1.localhost |
| Tenant 2 | tenant2 | tenant2.localhost |
| | | |
When developing locally, the URLs work fine. However, when I deploy to Google App Engine with a different domain, it probably won't work because my domain_url is hard-coded as tenantX.localhost.
I could write a script that changes the domain_url for each row in the table.
But I foresee changing domains again in the future, so I was wondering if there's some way to store the domain outside the database (eg in an environment variable) so it can be changed immediately for all tenants.
Thanks!
Write your own custom middleware (https://django-tenant-schemas.readthedocs.io/en/latest/advanced_usage.html).