Re: reduce number of DB-Queries

2012-09-21 Thread kloetpatra
I think aggregation can't be used because the calculations are a bit more complex than just the sum/average/count/min/max of one field. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: reduce number of DB-Queries

2012-09-21 Thread kloetpatra
Wow thanks! That's really going fast now. I would have never come to that idea :) One more question: Is this how you meant to set the instance variable or did you mean in another way? def __init__(self, *args, **kwargs): super(Player, self).__init__(*args, **kwargs)

reduce number of DB-Queries

2012-09-21 Thread kloetpatra
Hi! I have the following models: class Player(models.Model): name = models.CharField('Name', max_length=40) def __unicode__(self): return self.name def goals(self): g = 0 ms = Match.objects.select_related().filter( Q(opp1=self)|Q(opp2=self) ) for m

calculated fields with foreign keys

2012-09-20 Thread kloetpatra
Hi! I have the following models: class Player(models.Model): name = models.CharField('Name', max_length=40) pub_date = models.DateTimeField('date added', default=datetime.datetime.now) def __unicode__(self): return self.name def goals(self): g = 0 ms1 =