pythondjangodjango-modelsdumpdata

How to dumpdata from django-tenant-schemas?


I am trying to use manage.py dumpdata on my app's model but I am not able to see the json data in my dump file as I am using the django-tenant-schemas app to manage models for various clients. Is there any solution to dumpdata related to specific schema?


Solution

  • I found the solution to do so:-

    python manage.py tenant_command dumpdata --schema="schema-name" app_name.model_name --indent 4 > fixtures/dump.json
    

    Or you can use:-

    for t in $(./manage.py list_tenants | cut -f1);
    do
        ./manage.py tenant_command dumpdata --schema=$t --indent=2 auth.user > ${t}_users.json;
    done
    

    I found the answer here:-

    http://django-tenant-schemas.readthedocs.io/en/latest/use.html?highlight=dumpdata