你可以按以下方式链接查询:
values = [1,2,3]# Turn list of values into list of Q objectsqueries = [Q(pk=value) for value in values]# Take one Q object from the listquery = queries.pop()# Or the Q object with the ones remaining in the listfor item in queries: query |= item# Query the modelArticle.objects.filter(query)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)