【问题标题】:can't extract geo on mongoengine ListField(StringField()) - how come?无法在 mongoengine ListField(StringField()) 上提取地理信息 - 怎么会?
【发布时间】:2016-09-12 07:59:15
【问题描述】:

我的代码中没有“2dshpere”。 我的课很简单

class DbBatch(Document):
  start_time = DateTimeField(required = True)
  duration_seconds = IntField()
  run_on_port = ListField(StringField())
  batch_name = StringField(required = True)
  batch_parameters = EmbeddedDocumentListField(DevicePortParameter)
  statistics = EmbeddedDocumentListField(Statistics)

我只是在做

reg0_batch0 = DbBatch()
reg0_batch0.batch_name = 'reg0_batch2'
reg0_batch0.run_on_port = ['0']

我在保存文档时出错 - 为什么????这个简单的列表中没有 2d 球体或任何有趣的东西

# Saving to DB 
reg0_batch0.save()

# output 
......
File "C:\Python27\lib\site-packages\mongoengine\document.py", line 398, in save
raise OperationError(message % unicode(err))
OperationError: Could not save document 
(Can't extract geo keys: { _id: ObjectId('57d64f926151394b5c740fea'),
start_time: new Date(1473673632148), run_on_port: [ 0 ], 
batch_name: "reg0_batch2", batch_parameters: [], statistics: [] }  
Point must only contain numeric elements)

并且在清除 ListField 时我没有收到任何错误

reg0_batch0.run_on_port = []
reg0_batch0.save()

# good response - saved into DB 
Out[16]: <DbBatch: DbBatch object>

有什么想法吗?

顺便说一句 - 与 ListField(IntField()) 的结果相同

【问题讨论】:

    标签: mongodb mongoengine


    【解决方案1】:

    我清除了集合并重做 - 现在没有错误 - 不知道为什么首先出现错误 - 但无论如何它已经解决了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 2019-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多