n.i*_*imp 1 python django django-models
我正在尝试为 Django 中的模型提供初始数据。但是当我尝试运行时python manage.py loaddata <fixture path>出现以下错误:
django.core.serializers.base.DeserializationError: Problem installing
fixture '/home/location/fixtures/initial_data.json':
Expecting property name enclosed in double quotes: line 7 column 10 (char 119)
Run Code Online (Sandbox Code Playgroud)
我的装置或初始数据是这样的:
[
{
"model": "location.zipcode",
"pk": 1,
"fields": {
"zipcode": 79936,
}
},
{
"model": "location.zipcode",
"pk": 2,
"fields": {
"zipcode": 90011,
}
}
]
Run Code Online (Sandbox Code Playgroud)
我zipcode在邮政编码模型中有一个 IntegerField 。帮助将不胜感激。
尾随逗号在 JSON 中无效,因此请将其删除。
那会给出:
[
{
"model": "location.zipcode",
"pk": 1,
"fields": {
"zipcode": 79936
}
},
{
"model": "location.zipcode",
"pk": 2,
"fields": {
"zipcode": 90011
}
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1381 次 |
| 最近记录: |