2👍
✅
You can do:
d = Document.objects.filter(Q(title__contains=term) | Q(
content__contains=term) | Q(category__name__contains=term))
Here is the relevant documentation on lookups that span relationships
Source:stackexchange.com