【发布时间】:2021-08-11 02:22:18
【问题描述】:
我在 Django 中有以下模型:
class JobPost(models.Model):
company = models.CharField(blank=True, max_length=30, null=True)
job = models.CharField(blank=True, max_length=30, null=True)
category = models.CharField(blank=True, max_length=30, null=True)
description = models.TextField(blank=True, max_length=500, null=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.job
我有以下石墨烯模式:
class JobPostNode(DjangoObjectType):
class Meta:
# Assume you have an Animal model defined with the following fields
model = JobPost
filter_fields = {
'company': ['exact', 'icontains', 'istartswith'],
'job': ['exact', 'icontains', 'istartswith'],
'category': ['exact', 'icontains', 'istartswith'],
"description": ['exact', 'icontains', 'istartswith'],
}
interfaces = (relay.Node,)
class Query(graphene.ObjectType):
job = relay.Node.Field(JobPostNode)
all_jobs = DjangoFilterConnectionField(JobPostNode)
schema = graphene.Schema(query=Query)
我想使用icontains,而我将根据 OR 而不是 AND 获取数据;例如以下查询:
{
allJobs(job_Icontains: "t", company_Icontains: "v") {
edges {
node {
company
job
}
}
}
}
应返回工作中包含字母“t”或公司中包含字母“v”的数据,而不是工作中包含字母“t”和公司中包含字母“v”的数据。我该怎么做?
【问题讨论】:
标签: python django graphql graphene-python graphene-django