Django转储数据为单个模型? [英] Django dump data for a single model?

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

问题描述

可以在中执行 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屋!

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