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 related makes no sense. Marc On 23 Aug 2013 18:44, "Andrew Ingram" <[email protected]> wrote: > 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 <[email protected]> wrote: > >> 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 >>> idea, but I figured I might as well add it to the conversation anyway: >>> https://gist.github.**com/AndrewIngram/5636041<https://gist.github.com/AndrewIngram/5636041> >>> >>> 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 don't like the idea of mixing annotate() and prefetch_related(). >> Annotations work inside the query, prefetch_related runs additional queries. >> >> That being said I do like the idea of >> .annotate(active_authors=Count('authors').filter(active=True)). There is an >> old ticket about this sort of annotation, see >> https://code.djangoproject.com/ticket/11305. >> >> - Anssi >> >> -- >> 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. >> > > -- > 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. > -- 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.
