Django not like statement

流过昼夜 提交于 2019-12-23 12:08:09

问题


how to use not like in django queries

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

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

回答1:


use the exclude function and Q objects

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


来源:https://stackoverflow.com/questions/4193097/django-not-like-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!