bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 424 forks source link

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

Open aduquehd opened 6 years ago

aduquehd commented 6 years ago

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.

mikicz commented 6 years ago

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
aduquehd commented 6 years ago

Thank you so much!