在mongoengine过滤器查询中不能使用“ gte”

问题描述 投票:0回答:1

我有一个MongoEngine文档班的学生。。

class Student(Document):
    db_id = StringField()
    name = StringField()
    score = IntField()
    deleted = BooleanField(default=False, required=True)

我想以]查询>

Student.objects.filter(score__gte = 30)

但是我遇到类似AttributeError:'int'对象没有属性'get'

]的错误>

有人可以帮我这个忙吗?谢谢!

我有一个MongoEngine文档类Student ..类Student(Document):db_id = StringField()名称= StringField()分数= IntField()已删除= BooleanField(默认= False,必填= ...

python mongoengine
1个回答
0
投票
以下(最小)代码段工作正常

from mongoengine import * connect() class Student(Document): name = StringField() score = IntField() Student(name='Bob', score=35).save() print(Student.objects(score__gte=30)) # output: [<Student: Student object>]

© www.soinside.com 2019 - 2024. All rights reserved.