南(对于Django)可以将数据行插入数据库吗? [英] Can the South (for Django) insert rows of data into database?

查看:149
本文介绍了南(对于Django)可以将数据行插入数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个表,然后创建一个应该插入该表的数据列表。南方有能力做这样的事吗?如果是这样,你有没有提到告诉我怎么做?

I want to create a table, and then a list of data that should be inserted into that table. Does South have the capability to do such a thing? If so, do you have any reference as to show me how this can be done?

我想要能够做到这一点,因为在这一点上,似乎只有这样才能将完全相同的数据手动将它们自动插入到数据库中。

I want to be able to do this because at this point, it seems like the only way to have the 'exact' same data is to manually insert them into the database ourselves.

我想要一些在表中插入行的自动化方法。

I want some 'nice' automated way of inserting rows in a table.

推荐答案

你想使用 fixtures


  1. 在应用的文件夹中创建一个灯具目录。

  2. 在该文件夹中创建一个字典文件, intial_data.json(或XML / YAML)

  3. 使用要插入的数据填充文件。 示例

  4. 运行 manage.py loaddata< fixturename> ,其中< fixturename> 是您创建的夹具文件的名称

  1. Create a fixtures directory in your app's folder.
  2. Create a dictionary file in that folder, intial_data.json (or XML/YAML)
  3. Populate the file with the data you'd want to insert. Example
  4. Run manage.py loaddata <fixturename>, where <fixturename> is the name of the fixture file you've created.

南方以相同的方式处理这一点,但Django的核心方法似乎更有记载。

South handles this pretty much the same way, but it seems like Django's core approach is more documented.

这篇关于南(对于Django)可以将数据行插入数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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