Hi,

This is actually a simplified model of a more complex database. It seems
simple, but I am not able to get the ruight solution.

I have two tables, one a foreignkey of the other. The first table is a bill
and other one is a table where I can add items to be billed and their price.


I have a field called totalprice  in the table bill, which should end up
with a value of sum of all Item.price.

How do I populate the table bill's field gtotalprice without writing a
CUSTOM SQL Query, and only using core python code.

Also I need the sno (serial number to be incremented) for every item in a
unique bill. How do I do this?



class bill(models.Model):
    bill_reference = models.CharField(maxlength=100)
    bill_date = models.DateField(editable=False)
    totalprice = models.FloatField( editable=False)
    def__str__(self):
        return self.bill_reference

    def save(self):
        ......


class Item(models.Model):
    bill = models.ForeignKey(bill, edit_inline=models.STACKED,
num_in_admin=5)
    sno = models.IntegerField(editable=False)
    itemname = models.CharField(maxlength=100, core =True)
    price = models.IntegerField(core=True)


Any help is most welcome

Ramdas S

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to