mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +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:
parent
c8d61fa109
commit
7bbb6958dc
5 changed files with 112 additions and 23 deletions
|
|
@ -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']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue