instantiation document failed: to_python() missing 1 required positional argument: 'value'
regainOWO opened this issue · 2 comments
regainOWO commented
version
mongoengine: 0.27.0
pymongo: 4.3.3
code
from mongoengine import Document, StringField, ListField, FloatField, DictField
class Labels(Document):
name = StringField()
data = ListField(field=DictField)
version = FloatField(default=1.0)
if __name__ == '__main__':
name = '000000005802'
data = [
{'poly': [510.67, 324.92, 510.67, 367.99, 525.83, 367.99, 525.83, 324.92], 'name': 'bottle', 'difficult': 0},
{'poly': [550.33, 346.19, 550.33, 399.37, 559.83, 399.37, 559.83, 346.19], 'name': 'bottle', 'difficult': 0}
]
label = Labels(name=name, data=data)
print(label.to_json())
regainOWO commented
Traceback (most recent call last):
File "E:\GithubProjects\jp-sample\database\meta\labels.py", line 21, in <module>
label = Labels(name=name, data=data)
File "D:\Programs\Python\yoloserie\lib\site-packages\mongoengine\base\document.py", line 127, in __init__
value = field.to_python(value)
File "D:\Programs\Python\yoloserie\lib\site-packages\mongoengine\base\fields.py", line 379, in to_python
value_dict = {
File "D:\Programs\Python\yoloserie\lib\site-packages\mongoengine\base\fields.py", line 380, in <dictcomp>
key: self.field.to_python(item) for key, item in value.items()
TypeError: to_python() missing 1 required positional argument: 'value'
regainOWO commented
from mongoengine import Document, StringField, ListField, FloatField, DictField
class Labels(Document):
name = StringField()
data = ListField(field=DictField())
version = FloatField(default=1.0)
if __name__ == '__main__':
name = '000000005802'
data = [
{'poly': [510.67, 324.92, 510.67, 367.99, 525.83, 367.99, 525.83, 324.92], 'name': 'bottle', 'difficult': 0},
{'poly': [550.33, 346.19, 550.33, 399.37, 559.83, 399.37, 559.83, 346.19], 'name': 'bottle', 'difficult': 0}
]
label = Labels(name=name, data=data)
print(label.to_json())
workers fine