我试图找到如何执行not equal
和not in
过滤的解决方案,但由于缺乏经验,我无法找到解决方案
这是我当前结构的一部分
# result/models.py
class Result(models.Model):
...
object = models.ForeignKey(Object, on_delete=models.PROTECT)
...
# result/types.py
class ResultType(DjangoObjectType):
class Meta:
model = Result
filter_fields = {
...
'object__object_name': ['exact', 'icontains'],
...
}
convert_choices_to_enum = False
interfaces = (graphene.relay.Node,)
object = DjangoFilterConnectionField(ObjectType)
# result/queries.py
class Query(object):
results = DjangoFilterConnectionField(ResultType)
我希望能够执行类似以下内容的搜索:
# result/types.py
class ResultType(DjangoObjectType):
class Meta:
model = Result
filter_fields = {
...
'object__object_name': ['exact', 'icontains', 'notequal', 'notin'],
...
}
convert_choices_to_enum = False
interfaces = (graphene.relay.Node,)
object = DjangoFilterConnectionField(ObjectType)
因此,您可以执行下面的查询,就像使用not equal
和not in
一样
query {
results ( object_ObjectName__Notequal: "Pluto"){
edges {
node {
object {
objectName
}
}
}
}
}
用户tcleonard
向我展示了实现此结果的方法。
https://github.com/graphql-python/graphene-django/issues/1145
目前没有回答
相关问题 更多 >
编程相关推荐