django-queryset-2

Last Updated :
Discuss
Comments

Which query returns posts published after a given date while keeping only records with status set to published, and which operator filters values greater than the date?

Post.objects.filter(status='published', published__gt=date) which uses gt for greater-than

Post.objects.exclude(status='draft').filter(published__lt=date) which uses lt for less-than

Post.objects.get(status='published', published__lte=date) which uses lte for less-than-or-equal

Post.objects.all().exclude(published__gte=date) which uses gte for greater-than-or-equal

Tags:
Share your thoughts in the comments