I've got an invoice model that foreign key's to a customer model, when the invoice is saved I'm update a few fields in that related customer model to make other code in my setup work. I keep getting "unsupported operand type(s) for ** or pow(): 'Decimal' and 'NoneType'" whenever I try to save the foreignkey model:
class Customer(models.Model): """ Customer Model """ customer_id = models.CharField(max_length=10) customer_name = models.CharField(max_length=100) slug = models.SlugField(unique=True) outstanding_amount = models.DecimalField(editable=False, default='0.00') class CustomerInvoice(models.Model): customer = models.ForeignKey(Customer, related_name="customer_invoices") invoice_id = models.CharField(max_length=10, editable=False) invoice_paid_date = models.DateField(blank=True, null=True) invoice_total = models.DecimalField(max_digits=10, decimal_places=2, editable=False, default='0.00') def save(self): if not self.invoice_paid: self.customer.outstanding_amount = self.invoice_total self.customer.save() I'm thinking I'm looking too closely at something there where the problem might be in the related model: I'm missing something simple but what!? BTW these models are created in separate apps if that makes any difference. 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 -~----------~----~----~----~------~----~------~--~---