如何为包含外键和日期时间字段的 django 模型提供初始数据。
例如::
仲裁/models.py
class Question(models.Model):
user=models.ForeignKey(User)
created=models.DateTimeField(auto_now_add=True)
question=models.TextField()
tags=models.CharField(max_length=50)
quorum/fixtures/questions.json
[
{
"model": "quorum.question",
"pk": 1,
"fields": {
"question": "what is cryptography in computer science?",
"tags": "computer science, cryptography."
}
},
{
"model": "quorum.question",
"pk": 2,
"fields": {
"question": "How python language got name? from snake? is it from monty python circus performence(the projectile stuff)?",
"tags": "python"
}
}
]