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%";
To answer your specific question, there is no "not equal to" but that's probably because django has both "filter" and "exclude" methods available so you can always just switch the logic round to get the desired result.
The Django convention is to use the empty string, not NULL. The default values of null and blank are False. Also there is a special case, when you need to accept NULL values for a BooleanField , use NullBooleanField instead.
A QuerySet is a collection of data from a database. A QuerySet is built up as a list of objects. QuerySets makes it easier to get the data you actually need, by allowing you to filter and order the data.
use the exclude
function and Q
objects
Model.objects.exclude(Q(keyword__contains='undefined') | Q(keyword__contains='null'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With