Django: Multi Tenancy : Override Tenant Context

Question:

I have overridden django_tenants.utils.tenant_context to activate a timezone specific to the tenant.

class NewTenantContext(tenant_context): ...

I can use the new context like this

with ALSTenantContext(tenant): ...

All this works fine for a specific process to start for a tenant.

But how do I make sure NewTenantContext is used when tenant is set from Admin or API?

Asked By: Salil Satpute

||

Answers:

I am able to resolve this by overriding middleware django_tenants.middleware.TenantMainMiddleware

Answered By: Salil Satpute