View all speakers
Jacob Walls

Jacob Walls

Django has been an integral part of my journey as a developer from my training in music composition and technology through to building open-source web applications. Django contributor since 2020, Django Fellow since 2025.

Auto-prefetching with model field fetch modes in Django 6.1

Talk
Fri 17 Apr | 11:05
30min
AMPHITHEATRE
New in Django 6.1, model field fetch modes provide a way to avoid the deluge of queries from accessing un-fetched objects during a loop (also known as the "N+1 queries" problem). You may be familiar with how Django's prefetch_related() and select_related() methods can prevent these queries, but unlike those tools, the "fetch peers" mode does not require maintaining a list of fields to fetch. This can significantly improve project maintenance, especially when QuerySets are constructed at some distance from where they are used. In this talk, we'll cover what's new about fetch modes, what tradeoffs are entailed, how to configure fetch modes per-model via managers, and how to use the "raise" mode to surface issues in development or put guardrails around performance-intensive sections of code (like the django-seal package).
View session