Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
Roland, Shooting a bit in the dark but how about: ... select = { 'days_in_stock': "'%s' - transactie_datum_inkomend + 1" % (given_date.isoformat()), 'avg_days_instock': 'AVG(days_in_stock)', }) ... qs.annotate(Count('manufacturer')) ... Would that get you the group by and average field y

Re: Challenge with Annotate

2010-05-18 Thread Roland van Laar
On 05/18/2010 03:43 PM, Ian Lewis wrote: > Roland, > > Instead of using annotate, could you just add the avg_days_instock > field as another key in the select argument to extra? > Well how would I do that? Since I want the avg_days_instock calculated on a 'group_by' basis. To me it seems that I

Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
Roland, Instead of using annotate, could you just add the avg_days_instock field as another key in the select argument to extra? Ian On Tue, May 18, 2010 at 9:03 PM, Roland van Laar wrote: > Hello, > > Question: How do I calculate the Average of a calculated field. > > My (simplified) models.py

Challenge with Annotate

2010-05-18 Thread Roland van Laar
Hello, Question: How do I calculate the Average of a calculated field. My (simplified) models.py: Manufacturer(models.Model): name = models.CharField(length=100) Product(models.Model): name = models.CharField(length=100) Items(models.Model): manufacturer = models.Foreignkey(Manufa