mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #28096 -- Allowed prefetch calls with ModelIterable subclasses
Regression in 7ec330eeb9
.
Thanks Tim Graham for the review.
This commit is contained in:
parent
dff559ff83
commit
43b4a1618e
4 changed files with 21 additions and 3 deletions
|
@ -1260,7 +1260,7 @@ class Prefetch:
|
|||
self.prefetch_through = lookup
|
||||
# `prefetch_to` is the path to the attribute that stores the result.
|
||||
self.prefetch_to = lookup
|
||||
if queryset is not None and queryset._iterable_class is not ModelIterable:
|
||||
if queryset is not None and not issubclass(queryset._iterable_class, ModelIterable):
|
||||
raise ValueError('Prefetch querysets cannot use values().')
|
||||
if to_attr:
|
||||
self.prefetch_to = LOOKUP_SEP.join(lookup.split(LOOKUP_SEP)[:-1] + [to_attr])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue