:
-
Python 2.6.2版
-
Django(使用PostgreSQL)
问题
class OperationType(models.Model):
eid = models.IntegerField()
name = models.TextField(blank=True)
description = models.TextField(blank=True)
def __unicode__(self):
tpl = 'eid="', str(self.eid), '" name="', self.name, '"'
return ''.join(tpl)
现在我需要初始化它,例如使用以下数据:
0, "None"
1, "Add"
2, "Edit"
3, "Delete"
文件
initial_data.json
[
{
"model": "OperationType",
"pk": 1,
"fields": {
"eid": 0,
"name": "None",
"description": "Do nothing"
}
},
{
"model": "OperationType",
"pk": 2,
"fields": {
"eid": 1,
"name": "Add",
"description": "Adding transaction"
}
}
]