-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
e.g. https://wagtailcms.slack.com/archives/C81FGJR2S/p1762869979474629
Using the image listing, if you search by something and try to order by the usage count you get:
Cannot sort search results with field "usage_count". Please add index.FilterField("usage_count") to CustomImage.search_fields.
However, usage_count is an annotation on the results queryset, so adding index.FilterField("usage_count") fails with images.CustomImage: (modelsearch.W004) CustomImage.search_fields contains non-existent field 'usage_count', as expected. The workaround in this case is to define
def usage_count(self):
return self.get_usage().count()on the CustomImage object, but IMHO, this should just work.
Note: this is not limited to just core images/docs
Metadata
Metadata
Assignees
Labels
No labels