Django转储数据为单个模型? [英] Django dump data for a single model?
问题描述
可以在中执行 dumpdata
Django 只是一个单一的模型,而不是整个应用程序,如果是的话,怎么样?
Can I perform a dumpdata
in Django on just a single model, rather than the whole app, and if so, how?
对于一个应用程序,它将是:
For an app it would be:
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转储数据为单个模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!