Django不喜欢声明

时间:2010-11-16 10:21:53

标签: django django-templates django-views django-queryset

如何使用不像django查询

    Model.objects.filter(keywords not like "null" or "undefined")

       select * from model where keywords not like "%undefined%"  or keywords not like "%null%";

1 个答案:

答案 0 :(得分:7)

使用exclude函数和Q对象

Model.objects.exclude(Q(keyword__contains='undefined') | Q(keyword__contains='null'))