A better way of achieving this functionality would be the API proposed 
in https://code.djangoproject.com/ticket/17001

Marc

On Wednesday, 6 February 2013 00:29:15 UTC, Michal Novotný wrote:
>
> Hey, what about this 
> one: qs.prefetch_related('best_pizza__toppings__topping_type_*')
>
> It is intuitive and simple. But of course, that would mean to add wildcard 
> support everywhere.
>
> On Sunday, February 19, 2012 11:18:20 PM UTC+1, Yo-Yo Ma wrote:
>>
>> Speaking with regards to the ORM method documented at 
>>
>> https://docs.djangoproject.com/en/dev/ref/models/querysets/#prefetch-related 
>>
>> Of course, ``prefetch_related`` uses a Pythonic join to attach reverse- 
>> related objects and avoids the N+1 queries problem, which of course is 
>> great. However, if you use it like this: 
>>
>> >>> 
>> Restaurant.objects.prefetch_related('best_pizza__toppings__topping_type') 
>>
>> It doesn't seem to take advantage ``select_related`` (assuming that 
>> ``topping_type`` is a ``ForeignKey`` from ``Topping``. It instead 
>> sends a separate query for ``Topping`` and ``ToppingType``, joining 
>> them in Python. Is it feasible to modify ``prefetch_related`` use 
>> ``select_related`` when it encounters a ``ForeignKey``?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to