使用 Django dumpdata 转储整体数据的子集?

发布于 2024-08-31 04:30:57 字数 130 浏览 4 评论 0原文

我正在尝试使用 dumpdata 为数据库生成 JSON,该数据库对于 django 来说足够大,需要很长一段时间才能输出。有没有办法只转储字段的子集;比如说,100,用于测试?

我正在使用 MySQL 和 Django 1.0。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

九公里浅绿 2024-09-07 04:30:57

第三方 django 应用程序,django-test-utils 包含 makefixture 命令实现基本上是一个更智能的转储数据。您可以指定精确的模型名称以及要导出的 ID 范围(并且它将遵循相关对象)
示例:manage.py makefixture --format=xml --indent=4 proj.appname.modelname[1:101] >测试.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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文