问题描述
我可以在 Django 中执行 dumpdata
只是一个模型,而不是整个应用程序,如果是这样,如何?
Can I perform a dumpdata
in Django on just a single model, rather than the whole app, and if so, how?
对于应用程序,它是:
python manage.py dumpdata myapp
但是,我想要转储某些特定模型,例如myapp.mymodel".原因是,我在同一个应用程序中有一些巨大的、超过 300 万条记录的数据集,我不想丢弃这些数据集.
However, I want some specific model, such as "myapp.mymodel" to be dumped. The reason being, I have some huge, 3 million records plus, datasets in the same app that I would not like dumped.
推荐答案
从 1.1 及更高版本开始,Django dumpdata
管理命令允许您从单个表中转储数据:
As of version 1.1 and greater, the Django dumpdata
management command allows you to dump data from individual tables:
./manage.py dumpdata myapp1 myapp2.my_model
您还可以在命令行上分离多个应用程序和模型.这是规范定义:
You can also separate multiple apps and models on the command line. Here's the canonical definition:
django-admin dumpdata [app_label[.ModelName] [app_label[.ModelName] ...]]
这篇关于Django 转储单个模型的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!