The list filter, based on the price (USD) field plus the custom one that we just created, will be shown in the sidebar of the product list, as follows:
The PhotoFilter class has translatable title and query parameter names as properties. It also has two methods, as follows:
- The lookups() method that defines the choices of the filter
- The queryset() method that defines how to filter QuerySet objects when a specific value is selected
In the lookups() method, we define three choices, as follows:
- There are no photos
- There is one photo
- There is more than one photo attached
In the queryset() method, we use the annotate() method ...