wagtailwagtail-apiv2

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"

}


Solution

  • 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&...