django-tenant-schemas icon indicating copy to clipboard operation
django-tenant-schemas copied to clipboard

How can be executed a tenant command that be executed in all Tenants.

Open aduquehd opened this issue 7 years ago • 2 comments
trafficstars

Actually, I need to specify a tenant name.

I want to execute a script that populates some models data for all tenants. No just one.

aduquehd avatar Oct 04 '18 01:10 aduquehd

See https://django-tenant-schemas.readthedocs.io/en/latest/use.html#tenant_context

from tenant_schemas.utils import tenant_context

for tenant in Tenant.objects.all():
  with tenant_context(tenant):
    # do stuff in each tenant

mikicz avatar Oct 04 '18 08:10 mikicz

Thank you so much!

aduquehd avatar Oct 08 '18 18:10 aduquehd