DJANGO Queryset Q , F Filter

DJANGO


from django.db.models import Q

Item.objects.filter(Q(creator=owner) | Q(moderated=False))

 

Not equal to check

 

/media/uploads/2020/11/01/image.png

Filters can reference fields on the model

>>> from django.db.models import F
>>> Entry.objects.filter(number_of_comments__gt=F('number_of_pingbacks'))

 

Filter with Q and F

obj_livedata_high = Live_Price_Master.objects.filter(Q(LTP__gt=F('high52')) & Q(LTP__gt=0))
obj_livedata_low = Live_Price_Master.objects.filter(Q(LTP__lt=F('low52')) & Q(LTP__gt=0))

 

            Related