I'm using the Wagtail API (built on top of Django Rest Framework) to request information from our site. I know that I can filter the response by an APIField using the field name and a value: https://docs.wagtail.io/en/v2.5/advanced_topics/api/v2/usage.html#filtering
However I'd like to allow for a compound filter like so:
?slug=my-url-slug&foo=bar
The result of which would only return records which matched both criteria.
UPDATE Here's some snippets of code for reference:
class LandingPageBase(Page):
"""
LandingPageBase represents the base information needed for Eventbrite landing pages
"""
url_slug = models.SlugField(
max_length=255,
allow_unicode=True,
help_text='The slugified portion of a landing page url. Ex: sell-tickets',
)
locale = ParentalKey('home.Locale', on_delete=models.PROTECT, related_name='landing_pages')
api_fields = [
APIField('url_slug'),
APIField('locale_code'),
APIField('locale', serializer=serializers.StringRelatedField(source='locale_code')),
]
@property
def locale_code(self):
return self.locale.code
And here's the URL I'm using. http://localhost:32815/api/v2/page/?locale_code=de_de&url_slug=my-cool-landing-page-french&type=landing.RawHtmlLandingPage
I interpret this query to say "Give me a record that has X locale_code, Y url_slug, and Z type", in other words all AND statements. But instead what's happening is that I get the record for the url_slug and the locale_code doesn't seem to affect the result.