Hello,

I have an issue when trying to using prefetch_related in a queryset
inside a queryset already doing a prefetch_related. I have the
following code:


items = OrderItem.objects.prefetch_related(Prefetch('results'))

orders = Order.objects.prefetch_related(Prefetch('items', queryset=items))

freights = Freight.objects.prefetch_related(Prefetch('orders', queryset=orders))


Which results in the following error:

>
> Cannot find 'items' on OrderItem object, 'items__results' is an invalid 
> parameter to prefetch_related()


Models are linked with ForeignKeys (Result => OrderItem => Order => Freight).

What am I doing wrong ?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c41b84f-e9d0-4d41-9a50-a87f5ca2105b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to