{{{#!python
>>> Person.objects.select_related('foo')
django.core.exceptions.FieldError: Invalid field name(s) given in
select_related: 'foo'. Choices are: hometown
>>> Person.objects.select_related('hometown__foo')
django.core.exceptions.FieldError: Invalid field name(s) given in
select_related: 'foo'. Choices are: mayor
>>> Person.objects.select_related('hometown__name')
# query = select ... blah
[ Person object ...]
>>> Person.objects.select_related('name')
django.core.exceptions.FieldError: Non-relational field given in
select_related: 'name'. Choices are: hometown
}}}
Notice how it will happily accept the third one. Failing test attached.
--
Ticket URL: <https://code.djangoproject.com/ticket/24687>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "24687-test.diff" added.
* cc: github@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:1>
* status: new => assigned
* owner: nobody => timgraham
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/5421 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:2>
* needs_better_patch: 0 => 1
Comment:
A GIS failure needs to be addressed.
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:3>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"67732a9b183d2e84c85147b04fdf9499f4395ac6" 67732a9]:
{{{
#!CommitTicketReference repository=""
revision="67732a9b183d2e84c85147b04fdf9499f4395ac6"
Fixed #24687 -- Added select_related() validation for nested non-
relational fields.
The removed test was added in the original select_related() validation
patch (45d4e43d2d25b902e3821b612209afa951a8bcb8), but there doesn't
seem to be any reason for it.
Thanks Claude Paroz for help and review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24687#comment:6>