Update release notes

pull/8364/head
Andy Babic 2022-04-13 20:23:48 +01:00 zatwierdzone przez Matt Westcott
rodzic 2d5571f316
commit 7838e58095
1 zmienionych plików z 36 dodań i 0 usunięć

Wyświetl plik

@ -56,6 +56,42 @@ class LandingPage(Page):
Trying to upload an image that's a duplicate of one already in the image library will now lead to a confirmation step. This feature was developed by Tidiane Dia and sponsored by The Motley Fool.
### Image renditions can now be prefetched
When using a queryset to render a list of items with images, you can now make use of Django's built-in ``prefetch_related()`` queryset method to prefetch the renditions needed for rendering with a single extra query. For long lists of items, or where multiple renditions are used for each item, this can provide a significant boost to performance.
For example, say you were rendering a list of events (with thumbnail images for each). The queryset for your source data might look something like this:
```python
EventPage.objects.live().select_related("listing_image")
```
Now that renditions are prefetchable, you can reduce the number of additional database queries needed for rendering by updating the original queryset like so:
```python
EventPage.objects.live().select_related("listing_image").prefetch_related("listing_image__renditions")
```
If each image in your project has large numbers of renditions, you might want to consider using a ``Prefetch`` object to select only the renditions you need. For example:
```python
from django.db.models import Prefetch
from wagtail.images import get_image_model
# These are the renditions required for rendering
renditions = get_image_model().get_rendition_model().objects.filter(
filter_spec__in=["fill-300x186", "fill-600x400", "fill-940x680"]
)
# `Prefetch` is used to only fetch the required renditions
events = EventPage.objects.live().select_related("listing_image").prefetch_related(
Prefetch("listing_image__renditions", queryset=renditions)
)
```
This feature was developed by Andy Babic.
### Other features
* Upgrade ESLint and Stylelint configurations to latest shared Wagtail configs (Thibaud Colas, Paarth Agarwal)