Home > Mobile >  filtering objects in django with special rules
filtering objects in django with special rules

Time:11-05

How can you do a filter and do something like this in django

model.objects.filter(user_id = request.user.id , thing != 0)

I mean i wnat do something that it get only objects that their thing in not 0 .

CodePudding user response:

The exclude() method will do the job.

 model.objects.filter(user_id = request.user.id).exclude(thing = 0)
  • Related