-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from goodtune/list-tenants
Added list_tenants management command
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import csv | ||
import sys | ||
|
||
from django.core.management import BaseCommand | ||
from tenant_schemas.utils import get_tenant_model | ||
|
||
|
||
class Command(BaseCommand): | ||
def handle(self, *args, **options): | ||
columns = ('schema_name', 'domain_url') | ||
|
||
TenantModel = get_tenant_model() | ||
all_tenants = TenantModel.objects.values_list(*columns) | ||
|
||
out = csv.writer(sys.stdout, dialect=csv.excel_tab) | ||
for tenant in all_tenants: | ||
out.writerow(tenant) |