我在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
,而我将基于或不基于和获取数据;例如,以下查询:
{
allJobs(job_Icontains: "t", company_Icontains: "v") {
edges {
node {
company
job
}
}
}
}
应返回作业中有字母“t”或公司中有字母“v”的数据,而不是作业中的字母“t”和公司中的字母“v”。我该怎么做
我知道怎么做了!对于我的模式,我写了以下内容:
现在,使用以下查询,我得到了我想要的结果:
相关问题 更多 >
编程相关推荐