diff --git a/uncloud_pay/models.py b/uncloud_pay/models.py index 89ec917..efb7b07 100644 --- a/uncloud_pay/models.py +++ b/uncloud_pay/models.py @@ -327,7 +327,10 @@ class Bill(models.Model): orders = Order.objects.filter(bill=self) # The genrate_for method makes sure all the orders of a bill share the # same billing address. TODO: It would be nice to enforce that somehow... - return orders[0].billing_address + if orders: + return orders[0].billing_address + else: + return None # TODO: split this huuuge method! @staticmethod