Re: simple multiplication in models

2008-09-01 Thread akaihola
Fabio, The only reasons I can think of for this kind of denormalization of the database are performance (as you mentioned, unsignificant benefit here) or using the resulting value in a filter condition. The latter can be better worked around by mixing raw SQL with Django's ORM expressions (with

Re: simple multiplication in models

2008-08-25 Thread Fabio Natali
Chris Amico wrote: [...] > Awesome. That worked. Thanks all. > > > Class Item(models.Model): > > >     name = models.CharField(max_length=100) > > >     price = models.DecimalField(max_digits=9, decimal_places=2) > > >     quantity = models.IntegerField(default=1) > > >     total_cost = models.De

Re: simple multiplication in models

2008-08-25 Thread Chris Amico
Awesome. That worked. Thanks all. On Aug 25, 4:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-08-25 at 15:58 -0700, Chris Amico wrote: > > Changed the variable names to make it a little more readable. Method > > now returns "amount" (formerly "total"): > > > Class Item(model

Re: simple multiplication in models

2008-08-25 Thread Malcolm Tredinnick
On Mon, 2008-08-25 at 15:58 -0700, Chris Amico wrote: > Changed the variable names to make it a little more readable. Method > now returns "amount" (formerly "total"): > > Class Item(models.Model): > name = models.CharField(max_length=100) > price = models.DecimalField(max_digits=9, deci

Re: simple multiplication in models

2008-08-25 Thread Chris Amico
Changed the variable names to make it a little more readable. Method now returns "amount" (formerly "total"): Class Item(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=9, decimal_places=2) quantity = models.IntegerField(default=1) tot

Re: simple multiplication in models

2008-08-25 Thread nicksergeant
Should 'total_cost' simply: return total instead of: return total_cost(total) On Aug 25, 5:22 pm, Chris Amico <[EMAIL PROTECTED]> wrote: > This seems like it should be simple, but I'm getting errors. > > I have a model tracking individual purchases. User inputs an item cost > and quantity; I w

Re: simple multiplication in models

2008-08-25 Thread Karen Tracey
On Mon, Aug 25, 2008 at 5:22 PM, Chris Amico <[EMAIL PROTECTED]> wrote: > > This seems like it should be simple, but I'm getting errors. > > I have a model tracking individual purchases. User inputs an item cost > and quantity; I want the total cost calculated. Here are the relevant > parts: > > c