我正在尝试使用Django的“manage.py loaddata”命令将数据加载到mysql数据库中。当我尝试加载包含以下json内容的文件时,出现错误
DeserializationError: Problem installing fixture
'my_json.json': [u'No JSON object could be decoded']
当我删除名为“extra_data”的字段时,数据会成功加载。我发现字段“extra_data”是一个文本字段,因为它导致错误。如何在json中正确指定textfield以进行插入?
[
{
"pk": 2,
"model": "auth.user",
"fields": {
"username": "JamesButt"
}
}, {
"pk": 1,
"model": "socialaccount.socialaccount",
"fields": {
"uid": "JamesButt",
"last_login": "2013-11-22 11:11:11",
"user": 2,
"provider": "1",
"extra_data": "something",
"date_joined": "2013-11-22 11:11:11"
}
}
]
答案 0 :(得分:0)
extra_data = JSONField(default='{}')
,尝试使用JSON文档:
"extra_data": { "data": "something" }