List Info

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




Re: How to modify every element in a list all at once
country flaguser name
United States
2007-12-16 11:56:53
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 you post your models, please?

I take it price is a ForeignKey...

-Forest
-- 
Forest Bond
http://www.alittletooq
uiet.net
Re: How to modify every element in a list all at once
user name
2007-12-16 12:08:14
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 = models.ManyToManyField(Choice)

class Choice(models.Model):
    choice = models.ForeignKey(Collection,
edit_inline=models.TABULAR,
num_in_admin=5)
    size = models.ForeignKey(Size, core=True)
    price = models.ForeignKey(Price, core=True)
    orderdisplay = models.IntegerField()

class Price(models.Model):
    name = models.DecimalField(max_digits=6,
decimal_places=2)

    def __str__(self,):
        return str(self.name)

///////////////////////////////////////



On Dec 16, 11:56 am, Forest Bond <for...alittletooquiet.net> wrote:
> 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 you post your models, please?
>
> I take it price is a ForeignKey...
>
> -Forest
> --
> Forest Bondhttp://www.alittletooq
uiet.net
>
>  signature.asc
> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )