diff --git a/src/purchase/models.py b/src/purchase/models.py index 562424c..612c9c3 100644 --- a/src/purchase/models.py +++ b/src/purchase/models.py @@ -47,7 +47,10 @@ class PaymentMethod(Model): def default_product_display_order(): - return Product.objects.last().display_order + 1 + last = Product.objects.last() + if last is None: + return 1 + return last.display_order + 1 class ProductQuerySet(models.QuerySet):