Use Django dumpdata to dump a subset of overall data?

有些话、适合烂在心里 提交于 2019-12-03 15:31:32

问题


I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing?

I'm using MySQL and Django 1.0.


回答1:


A 3rd party django app, django-test-utils contains a makefixture command implementation which is basically a smarter dumpdata. You can specify exact model names with ID ranges to export (and it will follow related objects) Example: manage.py makefixture --format=xml --indent=4 proj.appname.modelname[1:101] > test.xml




回答2:


See also Django Selective Dumpdata which suggests Django Fixture Magic



来源:https://stackoverflow.com/questions/2733898/use-django-dumpdata-to-dump-a-subset-of-overall-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!