From fbed23e8e3ef59f52372e063f5d361b11f91fd2b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 25 Aug 2014 15:10:54 +0200 Subject: [PATCH] Add command list_tenants (fixes #5044) refs #5106 --- .../management/commands/list_tenants.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 entrouvert/djommon/multitenant/management/commands/list_tenants.py diff --git a/entrouvert/djommon/multitenant/management/commands/list_tenants.py b/entrouvert/djommon/multitenant/management/commands/list_tenants.py new file mode 100644 index 0000000..708e17c --- /dev/null +++ b/entrouvert/djommon/multitenant/management/commands/list_tenants.py @@ -0,0 +1,14 @@ +from django.core.management.base import BaseCommand +from entrouvert.djommon.multitenant.middleware import TenantMiddleware + +class Command(BaseCommand): + requires_model_validation = True + can_import_settings = True + option_list = BaseCommand.option_list + + def handle(self, **options): + all_tenants = TenantMiddleware.get_tenants() + + for tenant in all_tenants: + print("{0} {1}".format(tenant.schema_name, tenant.domain_url)) +