Browse Source

Expose Image.collection in the API

Sage Abdullah 2 months ago
parent
commit
75cfd70340
1 changed files with 4 additions and 0 deletions
  1. 4 0
      bakerydemo/base/models.py

+ 4 - 0
bakerydemo/base/models.py

@@ -21,6 +21,7 @@ from wagtail.contrib.settings.models import (
     register_setting,
 )
 from wagtail.fields import RichTextField, StreamField
+from wagtail.images.models import Image
 from wagtail.models import (
     Collection,
     DraftStateMixin,
@@ -37,6 +38,9 @@ from wagtail.search import index
 
 from .blocks import BaseStreamBlock
 
+# Allow filtering by collection
+Image.api_fields = [APIField("collection")]
+
 
 class Person(
     WorkflowMixin,