Changes between Initial Version and Version 3 of Ticket #37436
- Timestamp:
- Oct 22, 2026, 5:08:46 PM (2 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37436
- Property Triage Stage Unreviewed → Accepted
- Property Has patch set
- Property Patch needs improvement set
- Property Owner changed from to
- Property Severity Normal → Release blocker
-
Ticket #37436 – Description
initial v3 6 6 7 7 Consider two objects loaded with a deferred field using FETCH_PEERS: 8 8 {{{#!py 9 9 class Author(models.Model): 10 10 name = models.CharField(max_length=100) … … 19 19 20 20 _ = authors[1].name 21 21 }}} 22 22 Fetching authors[1].name causes fetch_many() to populate the field on all peers. This also replaces authors[0].name with the value currently stored in the database. 23 23 … … 31 31 32 32 fetch_many() uses in_bulk() to retrieve the deferred values and then indexes the returned dictionary for every peer: 33 33 {{{#!py 34 34 value_by_pk = ( 35 35 self.field.model._base_manager.using(db) … … 39 39 40 40 for instance in instances: 41 setattr(instance, attname, value_by_pk[instance.pk])42 41 setattr(instance, attname, value_by_pk[instance.pk]) 42 }}} 43 43 in_bulk() does not include primary keys for rows that no longer exist. Consequently, if one peer has been deleted, accessing the deferred field on another existing peer can raise KeyError. 44 44