【问题标题】:Django not like statementDjango 不喜欢声明
【发布时间】:2011-05-10 17:40:03
【问题描述】:

如何在 django 查询中使用 not like

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

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

【问题讨论】:

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


    【解决方案1】:

    使用exclude 函数和Q 对象

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-22
      • 1970-01-01
      • 2020-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多