Skip to content
Justice Tech School

exclude and Q Objects

Q combines conditions with OR.

Example
from django.db.models import Q
Post.objects.exclude(active=False)
Post.objects.filter(Q(title__icontains="a") | Q(body__icontains="a"))

Exercise

Exclude.

Post.objects.(x=1)

Quiz Test

Which operator means OR in Q?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.