#28175 closed Bug (fixed)
__in query on parent model no longer works in 1.11
Description (last modified by ) ¶
I have models
class Place(models.Model): pass class Community(Place): place_ptr = models.OneToOneField(Place, parent_link=True, on_delete=models.CASCADE, primary_key=True, serialize=False, related_name='+') class Potential(models.Model): community = models.ForeignKey(Community, on_delete=CASCADE)
and in 1.10 I can do
Potential.objects.filter(community__in=Place.objects.all())
but in 1.11 this fails with
django.core.exceptions.FieldError: Cannot resolve keyword 'place_ptr' into field. Choices are: [...]
In both versions
Potential.objects.filter(community=Place.objects.first())
works fine.
It's not clear to me from the docs whether the 1.10 behavior was intended, though.
It appears that adding the lines
elif getattr(self.lhs.field.target_field, 'primary_key', False): target_field = 'pk'
to django/db/models/fields/related_lookups.py at line 92 fixes this problem.
Change History (7)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 8 years ago
Cc: | added |
---|
comment:4 by , 8 years ago
Cc: | added |
---|
I find it a bit odd that we allow Place
to be used when Community
is expected (Community
is a Place
but not the other way around) but since this was allowed before we should fix that.
Note:
See TracTickets
for help on using tickets.
Bisected to 1bc249c2a67c24fcd28436c85388eff1d826e305.