bernardopires / django-tenant-schemas

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

how to launch tenant_command loaddata from views with fixtures #685

Open guillaumensft opened 2 years ago

guillaumensft commented 2 years ago

python manage.py tenant_command loaddata --schema="superchef" core\fixtures\fixtures.json from the views

guillaumensft commented 2 years ago
def loaddata(self, schema, file):
    if os.path.splitext(file)[1] == '.json' and file != 'initial_data.json':
        schema = f'--schema="{schema}"'
        os.system(f"python manage.py tenant_command loaddata {schema} {file}")