#23739: django 1.7.1 defer() throws AttributeError when using related_name
-------------------------------------+-------------------------------------
Reporter: farhan85 | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: defer related_name | Triage Stage: Accepted
AttributeError RelatedObject rel |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):
* status: new => closed
* resolution: => invalid
Comment:
The problem seems to be an invalid `select_related()` query. On Django
1.9:
{{{
>>>
ModelA.objects.filter(name='').select_related('model_b').defer('model_b__name')
django.core.exceptions.FieldError: Invalid field name(s) given in
select_related: 'model_b'. Choices are: (none)
}}}
You should be using `prefech_related()` when querying reverse foreign
keys.
--
Ticket URL: <https://code.djangoproject.com/ticket/23739#comment:7>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.551b322d4e0a3f42f2fa488380639c0f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.