Re: Custom prefetches (#17001)

2013-08-26 Thread Ionel Cristian Mărieș
Just a small note, I've done a small prefetch framework (mind you, before prefetch_related was implemented) here: https://github.com/ionelmc/django-prefetch It allows you to have a tailored prefetching process. It's a bit low level but it supports all the scenarios you mentioned. If you think

Re: Custom prefetches (#17001)

2013-08-26 Thread Chris Adams
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

Re: Custom prefetches (#17001)

2013-08-26 Thread Marc Tamlyn
I think that restriction is reasonable. So this wouldn't work: Publisher.objects.prefetch_related('authors', to_attr='authors_by_age', queryset=Author.objects.order_by('age')).prefetch_related(' authors_by_age__books') But this would:

Re: Custom prefetches (#17001)

2013-08-26 Thread Anssi Kääriäinen
On Friday, August 23, 2013 6:03:13 PM UTC+3, Marc Tamlyn wrote: > > Ticket #17001 concerns the ability to customise the querysets used when > using `prefetch_related()`. This has a working implementation with a less > than ideal API - see the patches on the ticket. > > As the API design seems to

Re: Custom prefetches (#17001)

2013-08-23 Thread Marc Tamlyn
The other restriction imposed by your suggested api is that the Count or Model list will presumably only know the standard queryset api - with a queryset= parameter any custom qs methods will work. This is perhaps more necessary in the annotate case as it is naturally a restricted api - select

Re: Custom prefetches (#17001)

2013-08-23 Thread Andrew Ingram
Yeah, that was Marc's main issue with the idea too. Based on that distinction it makes sense to keep the two as separate concepts, but as far as API design is concerned it makes sense to try and make them feel similar. On 23 August 2013 18:25, Anssi Kääriäinen wrote: >

Re: Custom prefetches (#17001)

2013-08-23 Thread Anssi Kääriäinen
On Friday, August 23, 2013 6:25:42 PM UTC+3, Andrew Ingram wrote: > > I'd love to see this solved. I'm not sold on the API, but then again I've > yet to see a single suggested API for this problem that I actually like. > > I showed you this a little while ago, you had some reservations with my >

Re: Custom prefetches (#17001)

2013-08-23 Thread Andrew Ingram
I'd love to see this solved. I'm not sold on the API, but then again I've yet to see a single suggested API for this problem that I actually like. I showed you this a little while ago, you had some reservations with my idea, but I figured I might as well add it to the conversation anyway:

Custom prefetches (#17001)

2013-08-23 Thread Marc Tamlyn
Ticket #17001 concerns the ability to customise the querysets used when using `prefetch_related()`. This has a working implementation with a less than ideal API - see the patches on the ticket. As the API design seems to be the main issue here, Anssi and I bounced some ideas around on IRC, and I