#35950 closed Bug (fixed)
Fix refreshing of related fields when one field is deferred
Description ¶
In #35044, we fixed the issue where loading a deferred field would clear related objects.
But it left a bug where refreshing all fields explicitly with refresh_from_db()
would no longer clear related objects *if* the model instance had any deferred fields.
This would work on Django 5.0 but is broken on 5.1:
book = Book.objects.defer('title').get(pk=1) assert book.author is not None # fetch related object Author.objects.all().delete() book.refresh_from_db() assert book.author is None # should have been reset by the refresh
Fix incoming.
Change History (9)
comment:1 by , 3 months ago
Has patch: | set |
---|
comment:2 by , 3 months ago
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
comment:3 by , 3 months ago
Cc: | added |
---|
comment:4 by , 3 months ago
Resolution: | worksforme |
---|---|
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
I managed to reproduce locally with the additional test provided in the PR.
comment:5 by , 3 months ago
Needs documentation: | set |
---|---|
Severity: | Normal → Release blocker |
Thank you - bisected to 73df8b54a2fab53bec4c7573cda5ad8c869c2fd8
Adam can you add a release note?
comment:6 by , 2 months ago
Needs documentation: | unset |
---|
comment:7 by , 2 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
I've not been able to replicate following the instructions on Django 5.1.3