#24612: Confusing error message when using only/defer through deleted related
field
-------------------------------------+-------------------------------------
Reporter: no | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 1.8
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by JaeHyuckSa):
* resolution: => worksforme
* status: new => closed
Comment:
I rechecked this on the current main branch and can no longer reproduce
the issue.
Using the exact model setup from the ticket, the following query now works
as expected:
{{{
#!python
list(Publisher.objects.only("books__author__name"))
}}}
The previously reported
{{{
AttributeError: 'ManyToOneRel' object has no attribute 'attname'
}}}
no longer occurs.
Looking at the code, this seems to have been fixed as a side effect of the
changes in #21204, which rewrote the only() / defer() machinery.
The old deferred_to_data() logic only treated reverse OneToOne relations
specially, while reverse ForeignKey relations (ManyToOneRel) still went
through remote_field.model. That logic was replaced entirely in #21204, so
the original failure mode doesn’t appear to be reachable anymore.
--
Ticket URL: <https://code.djangoproject.com/ticket/24612#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019b5aa9edd6-185321f7-6693-47f0-a624-cc266379ac80-000000%40eu-central-1.amazonses.com.