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, 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)
Why is Price a separate model? That is going to make your
algorithm necessarily
more complicated. You might have a good reason, but it's
not apparent to me.
This would be simpler:
class Choice(models.Model):
...
price = models.DecimalField(max_digits = 6
decimal_places = 2)
...
Then you could use one of the algorithms that Ned and I
suggested.
-Forest
--
Forest Bond
http://www.alittletooq
uiet.net
> 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
|