$ the-wire · showcase
Faster M2M related managers, verbatim tokenization fixed
By RepoJournal · Filed · About Django · Composed from the cited sources · methodology
Django landed a long-sought reduction in the cost of building many-to-many related managers, alongside a fix for verbatim template blocks that mis-tokenized until now.
Fixed #32980 -- Reduced cost of building M2M related managers. django/django
The many-to-many manager now hoists relation-only attributes of ManyRelatedManager to class level so __init__() does only per-instance work, and the reverse FK manager skips router.db_for_read() and connections[db] lookups in _apply_rel_filters. Cost of building related managers drops without the per-instance caching that was reverted in an earlier attempt.
Fixed #32980 -- Optimized ManyRelatedManager.__init__(). django/django
Attributes on ManyRelatedManager that did not vary per instance no longer get computed in __init__(). This is the commit-level half of the same ticket-32980 effort raised on the Django forum, so the two changes land as one optimization.
Fixed #23424 -- Corrected tokenization of verbatim blocks. django/django
Verbatim template blocks are now tokenized correctly, cherry-picked from an earlier PR. Templates using {% verbatim %} with content that previously tripped the lexer should render as written.
Fixed #37418 -- Fixed JSONField/HStoreField crash on deeply nested JSON. django/django
forms.JSONField.to_python() and bound_data() caught only json.JSONDecodeError, so input nested past the recursion limit raised RecursionError and returned HTTP 500 instead of "Enter a valid JSON." The contrib.postgres HStoreField form field had the same pattern; roughly 4 KB of input is enough to trigger it. All three sites now catch RecursionError.
Add benchmark for large prefetch_related() batch django/django-asv
The django-asv suite gained a time_query_prefetch_large benchmark with 2,000 authors and book managers, plus a MultipleChoiceField.validate() benchmark and fresh ubuntu-latest results, to measure the prefetch_related() work above.