使用Django dumpdata转储整个数据的子集? [英] Use Django dumpdata to dump a subset of overall data?

查看:328
本文介绍了使用Django dumpdata转储整个数据的子集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用dumpdata为数据库生成JSON,该数据库足够大,django需要很长时间才能输出。是否有任何方式只转储一部分字段;说100,用于测试?

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?

我正在使用MySQL和Django 1.0。

I'm using MySQL and Django 1.0.

推荐答案

第三方django应用, django-test-utils 包含 makefixture 命令实现,基本上是一个更智能的dumpdata。您可以指定要导出的ID范围的精确型号名称(它将跟随相关对象)
示例: manage.py makefixture --format = xml --indent = 4 proj.appname.modelname [1:101]> test.xml

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

这篇关于使用Django dumpdata转储整个数据的子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆