gpt4 book ai didi

python - Mongoengine PointField 给出预期的位置对象,位置数组格式不正确错误

转载 作者:可可西里 更新时间:2023-11-01 09:36:45 28 4
gpt4 key购买 nike

我有一个模型如下:

class Station(Document):
location = PointField()

尝试写入数据如下:

station = Station()
station.location = {
"type": "Point",
"coordinates": [
81.4471435546875,
23.61432859499169
]
}
station.save()

但是这给出了错误Could not save document (location object expected, location array not in correct format)

Mongoengine 文档说这样的字典应该没问题。我在这里错过了什么?

最佳答案

我曾经遇到过类似的问题,就我而言,这是因为我使用 GeoPointField 构建第一个原型(prototype)然后移动到 PointField 而没有删除或迁移我的数据库,对我来说,因为数据库中只有虚拟数据,所以问题在开始新的我的数据库完全删除后解决。希望对您有所帮助。

关于python - Mongoengine PointField 给出预期的位置对象,位置数组格式不正确错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20097668/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com