I'd like to build object relations (Model classes) without saving them to the database to predict a price for a specific order. Let's say I have this:
class Order(Model): id = models.AutoField(primary_key=True) number = models.IntegerField() def total(self): return sum([p.price for p in self.product_set]) class Product(Model): id = models.AutoField(primary_key=True) order = models.ForeignKey(Order) price = models.DecimalField() order = Order(number=1) # Now the nex line throws an error if we did not save the order here order.product_set.create(Product(price=20.0)) assert order.total() == 20.0 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---