ogholami
ogholami

Reputation: 31

filtering ParentalManyToManyField by query param in wagtail API

I have a wagtail Page model like:

class PropertyPage(Page):
    ...
    categories = ParentalManyToManyField('property.PropertyCategory', blank=True)

Is it possible to have a query param to filter multiple values base on it?

/api/v2/pages/?type=property.PropertyPage&categories=1,2,3,...

right now I get this error:

"message": "query parameter is not an operation or a recognised field: categories"

}

Upvotes: 1

Views: 529

Answers (1)

ogholami
ogholami

Reputation: 31

So, my requirement was to filter a "ParentalManyToManyField" by multiple value and it can be done by query params in this format:

/api/v2/pages/?type=property.PropertyPage&categories=1&categories=2&...

Upvotes: 1

Related Questions