Saturday, February 26, 2011

Re: foreign key reference in the 'def' to calculate tax

Hi,

> class TaxReference(models.Model):
> tax_multiplier = models.DecimalField()

> class Product(models.Model):
> price = models.DecimalField(max_digits=10, decimal_places=2)
> tax = models.ForeignKey(TaxReference)
> def taxedprice(self):
> return self.price*TaxReference.tax_multiplier
>
> The very last line of code is what I'm trying to accomplish.

Is this what you want?

def taxedprice(self):
return self.price * self.tax.tax_multiplier


Cheers,

--
Pascal Germroth

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment