Re: How to modify every element in a list all at once

2007-12-17 Thread Andreas Pfrengle
You have to convert s.price.name to float (or .9 to a DecimalObject if the float-precision should be a problem). This should work: for s in s2: s.price.name = float(s.price.name) * .9 s.price.save() On Dec 16, 8:43 pm, Greg <[EMAIL PROTECTED]> wrote: > Shabda, > I added the

Re: How to modify every element in a list all at once

2007-12-16 Thread Greg
Shabda, I added the following code to my view: for s in s2: s.price.name *= s.price.name * .9 s.price.save() However, I now get the error: TypeError at /plush/chandra/antara/108/multi/ unsupported operand type(s) for *: 'Decimal' and 'float' On Dec 16,

Re: How to modify every element in a list all at once

2007-12-16 Thread shabda
How about for s in s2: s.price.name *= s.price.name * .9 s.price.save() You are getting a type error coz you can not mutlipy a Model object by float, and that is what s.price is. BTW s2[0].price * .9 would not have worked as well, because of the same reasons! On Dec 16, 11:08

Re: How to modify every element in a list all at once

2007-12-16 Thread Forest Bond
Hi, On Sun, Dec 16, 2007 at 10:08:14AM -0800, Greg wrote: > > Forest, > Here are my models > > class Style(models.Model): > name = models.CharField(maxlength=200, core=True) > image = models.ForeignKey(Photo) > collection = models.ForeignKey(Collection, > edit_inline=models.TABULAR,

Re: How to modify every element in a list all at once

2007-12-16 Thread Greg
Forest, Here are my models class Style(models.Model): name = models.CharField(maxlength=200, core=True) image = models.ForeignKey(Photo) collection = models.ForeignKey(Collection, edit_inline=models.TABULAR, num_in_admin=1, num_extra_on_change=3) sandp =

Re: How to modify every element in a list all at once

2007-12-16 Thread Forest Bond
Hi, On Sun, Dec 16, 2007 at 08:37:08AM -0800, Greg wrote: > I've tried the following: > > for s in s2: > s.price *= s.price * .9 > > However, I still get the following error: > > TypeError at /plush/chandra/antara/108/multi/ > unsupported operand type(s) for *: 'Price' and 'float' Can

Re: How to modify every element in a list all at once

2007-12-16 Thread Forest Bond
Hi, On Sun, Dec 16, 2007 at 07:59:52AM -0800, Greg wrote: > I've added that code into my view. However, now I'm getting the > following error: > > TypeError at /manu/coll/style/ > unsupported operand type(s) for *=: 'Price' and 'float' > > > > I can't do a int(s.price),

Re: How to modify every element in a list all at once

2007-12-16 Thread Greg
Ned, I've added that code into my view. However, now I'm getting the following error: TypeError at /manu/coll/style/ unsupported operand type(s) for *=: 'Price' and 'float' I can't do a int(s.price), because then I get a 'Can't assign to function call' error. On Dec 15,

Re: How to modify every element in a list all at once

2007-12-15 Thread Ned Batchelder
for s in s2: s.price *= .9 --Ned. Greg wrote: > Hello, > I have the following list: > > [, )>, Small'>, )>, , )>, > , )>, , > )>] > > In my view I want to be able to modify the Price of each element. I > want to times the price of each element by .9. Here is my code that > creates the

How to modify every element in a list all at once

2007-12-15 Thread Greg
Hello, I have the following list: [, )>, , )>, , )>, , )>, , )>] In my view I want to be able to modify the Price of each element. I want to times the price of each element by .9. Here is my code that creates the above list: s2 = b.sandp.order_by('orderdisplay') I know that I can do