On Fri, Aug 5, 2011 at 7:51 AM, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > Without more informations about your models (and specially the > relationships), it's going to be rather difficult. As a general > consideration, if your Claim model can access these other models thru > relationships, well you just have to follow the relationships. This is > basic Django ORM stuff, well explained in the FineManual.
Hi I have: class Product(models.Model): ndc = models.CharField(max_length=50) product_name = models.CharField(max_length=50) quantity = models.IntegerField() ... class Pricing(models.Model): ndc = models.ForeignKey(Product) # wholesale acquisition cost wac = models.DecimalField(max_digits=17, decimal_places=8) ... class Contract(models.Model): name = models.CharField(max_length=100) products = models.ManyToManyField(Product, through='ContractProduct') class ContractProduct(models.Model): contract = models.ForeignKey(Contract) ndc = models.ForeignKey(Product) wac = models.ForeignKey(Pricing) rebate_pct = models.DecimalField(max_digits=17, decimal_places=8) admin_pct = models.DecimalField(max_digits=17, decimal_places=8) class Claim(models.Model): contract = models.ForeignKey(Contract) ndc = models.ForeignKey(Product) quantity = models.IntegerField(blank=True, null=True) I need a view where for every row returned from Claim I make a calculation based on quantity from the Claim, rebate_pct and wac. Is it possible to write a model method that would access these fields from the other tables? Thanks. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.