无法在mongoengine上提取地理位置ListField(StringField()) - 怎么来的?

时间:2016-09-12 07:59:16

标签: mongodb mongoengine

我的代码中没有'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>

任何想法?

BTW - 与ListField(IntField())

的结果相同

1 个答案:

答案 0 :(得分:0)

我清除了收集和重做 - 现在没有错误 - 不知道为什么错误在那里 - 但无论如何它已经解决了