On Friday, August 23, 2013 11:25:42 AM UTC-4, Andrew Ingram wrote:

> Essentially, I'm wondering if extending the prefetch_related concept is 
> the right approach, and whether it's instead worth exploring the more 
> general idea of "attaching stuff to models at the ORM level". There're a 
> lot of useful concepts from other ORMs related to attaching prebuilt data 
> structures like arrays, dicts, calculated values, filtered annotations, etc 
> to models. The problems all seem somewhat related, and I'm worried about 
> the possibility of solving them all in completely different ways.
>

I've found simonw's django-queryset-transform 
<https://github.com/simonw/django-queryset-transform>incredibly 
useful for this class of work in the past for precisely that reason. The 
proposed API above would work for my most common use (filtered prefetches, 
e.g. loading object translations in the current language) but in most cases 
I've been able to get significant benefits by doing things like using 
.values_list() to attach only the fields I actually need or retrieve 
certain common lookups from a cache. Being able to run pure Python code 
makes this rather easy and reduces the temptation to cram too much logic 
into an ORM chain.

Chris

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to