From dc7a465a8cd7d20a7e082384fcfe39f69b7674b4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 10 May 2020 14:22:09 +0200 Subject: [PATCH] Fix exception if first order does not have billing address --- uncloud_pay/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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