user_image
By  用户5952078759    On   2017年12月25日 13:09

感谢博主的答复,使用Q表达式确实更加容易理解一些。 我今天用一组数据测试了下,两条语句都应为 and 关系。 也就是:①select * from class where not (item1=equation1 and item2=equation2); ②select * from class1 as a,class2 as b where a.id = b.pid and not (b.item1=equation1 and b.item2=equation2) 测试语句模型: Blog.objects.exclude(entry__pub_date__gt=datetime.date(2005,1,3), entry__headline='headtest').values(); Entry.objects.exclude(pub_date__gt=datetime.date(2005,1,3), headline='headtest').values(); 测试数据概况: Blog中两条数据 Entry中一条外键关联Blog_id=1的数据