$ the-wire · showcase
Django fixes changelist search crashes and boosts djangoproject.com search speed
By RepoJournal · Filed · About Django
Django fixed a changelist search crash and over-matching bug, while djangoproject.com cut search page load time by 600ms.
Django fixed a changelist search crash and over-matching bug in `__exact` `search_fields` for non-text fields [1]. Fields with choices now properly reject invalid terms instead of letting them crash the changelist with an ORM error. Two related fixes restore database routing hints for custom prefetch querysets on forward `ForeignKey` and reverse `OneToOneField` paths [2] [3], which had regressed in Django 6.1 and could cause routers to pick the wrong database. Also, `RelatedIn` lookup preparation got a performance improvement [4]. On djangoproject.com, search performance improved significantly: the expensive headline annotations were moved after the paginator's limit is applied, reducing page load time from ~850ms to ~250ms for large result sets like "Model" [5] [6]. A deterministic sort was also added for search results [7]. The Teams page title was updated to an h1 tag and now includes "Working Groups" [8].
Action items
- → Upgrade Django to a version containing these fixes if you use `__exact` search_fields with choices fields django/django [plan]
- → Monitor djangoproject.com search for any residual slow queries django/djangoproject.com [monitor]
References
- [1] Fixed #37263 -- Fixed changelist __exact search crashes and over-matching. ↗ django/django
- [2] Fixed #37300 -- Fixed database routing for custom forward prefetch querysets. ↗ django/django
- [3] Fixed #37300 -- Preserved parent instance hints on custom Prefetch querysets. ↗ django/django
- [4] Fixed #37237 -- Improved RelatedIn lookup preparation performance. ↗ django/django
- [5] Improve search performance ↗ django/djangoproject.com
- [6] Avoid expensive search headline calculations ↗ django/djangoproject.com
- [7] Use a deterministic sort for search results ↗ django/djangoproject.com
- [8] Updated Teams page title to h1 tag and include "Working Groups". ↗ django/djangoproject.com