Django初始数据序列化错误

时间:2015-04-22 16:16:54

标签: python django django-models

我正在尝试为Django中的模型提供初始数据。但是当我尝试运行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) 时,我收到以下错误:

[
{
    "model": "location.zipcode",
    "pk": 1,
    "fields": {
      "zipcode": 79936,
     }
},
{
    "model": "location.zipcode",
    "pk": 2,
    "fields": {
        "zipcode": 90011,
    }
}
]

我的灯具或初始数据是这样的:

zipcode

我在Zipcode模型中将public decimal? FyTotalCost { get; set; } 作为IntegerField。 将不胜感激。

1 个答案:

答案 0 :(得分:3)

尾随逗号在JSON中无效,请删除它们 这会给:

[
{
    "model": "location.zipcode",
    "pk": 1,
    "fields": {
      "zipcode": 79936
     }
},
{
    "model": "location.zipcode",
    "pk": 2,
    "fields": {
        "zipcode": 90011
    }
}
]