Django 1.1 release candidate available
djangoproject.com
djangoproject.com
articles = Article.objects.filter(share__sharedOn__range=date_range).distinct()
articles = sorted(articles,key=lambda k: k.TotalRecipients(date_range),reverse=True)
which was achingly slow because it involved making a couple thousand SQL queries during the sorting phase. With annotation we can just do: articles = Article.objects.filter(share__sharedOn__range=date_range)\
.annotate(total_recipients=Count('shares__recipients')).order_by('total_recipients')
which is much much faster and more efficient. Without annotation, we would have had to manually write the SQL or denormalize a bunch of ManyToMany fields, neither of which I was too excited about.I totally understand you, but, I think its the best way to go, of course this is one example, and its very complicated, most of the time you'll only need one of those parameters.
http://docs.djangoproject.com/en/dev/releases/1.1-beta-1/#re...
Proxy models, deferred models seem like awesome features.
That'll be nice for testing.