1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Allowed custom querysets when prefetching single valued relations

The original patch for custom prefetches didn't allow usage of custom
queryset for single valued relations (along ForeignKey or OneToOneKey).
Allowing these enables calling performance oriented queryset methods like
select_related or defer/only.

Thanks @akaariai and @timgraham for the reviews. Refs #17001.
This commit is contained in:
Loic Bistuer
2014-01-17 01:24:39 +07:00
committed by Anssi Kääriäinen
parent c8d61fa109
commit 7bbb6958dc
5 changed files with 112 additions and 23 deletions

View File

@@ -170,8 +170,10 @@ class Comment(models.Model):
## Models for lookup ordering tests
class House(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=255)
owner = models.ForeignKey('Person', null=True)
main_room = models.OneToOneField('Room', related_name='main_room_of', null=True)
class Meta:
ordering = ['id']