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
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
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
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
4 matches
Mail list logo