Mongoengine PointField提供预期的位置对象,位置数组格式错误 [英] Mongoengine PointField gives location object expected, location array not in correct format error

查看:286
本文介绍了Mongoengine PointField提供预期的位置对象,位置数组格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模型如下:

class Station(Document):
    location = PointField()

尝试按以下方式写入数据:

Trying to write data as follows:

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文档说这样的字典应该可以.我在这里想念什么?

Mongoengine documentation says such a dictionary should be OK. What am I missing here?

推荐答案

我先使用了GeoPointField,然后将其转换为PointField.我将数据删除了集合中的数据,但没有删除集合本身,因此ehich造成了这个问题.

I had used GeoPointField first and then converted to PointField. I had dropped the data in the collection but not the collection itself, ehich created this problem.

删除集合即可解决问题.

Dropping the collection solved the issue.

这篇关于Mongoengine PointField提供预期的位置对象,位置数组格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆