[Django]-Django filter ManyToMany field

4👍

Specify categories as a keyword argument:

filtered_pages = Page.objects.filter(categories=category1)

You can also use the category object’s page_set to get related pages:

filtered_pages = category1.page_set.all()

Leave a comment