diff --git a/poizonstore/settings.py b/poizonstore/settings.py index 0b6a872..8a60c8f 100644 --- a/poizonstore/settings.py +++ b/poizonstore/settings.py @@ -68,6 +68,7 @@ INSTALLED_APPS = [ 'djoser', 'debug_toolbar', 'django_filters', + 'mptt', 'store' ] diff --git a/store/admin.py b/store/admin.py index dccc5ff..88d1cd4 100644 --- a/store/admin.py +++ b/store/admin.py @@ -2,8 +2,6 @@ from django.contrib import admin from django.contrib.admin import display from mptt.admin import MPTTModelAdmin -from .models import Category, Checklist, GlobalSettings, PaymentMethod, Promocode, User, Image, Client - from .models import Category, Checklist, GlobalSettings, PaymentMethod, Promocode, User, Image diff --git a/store/models.py b/store/models.py index ddd6468..28989cb 100644 --- a/store/models.py +++ b/store/models.py @@ -394,9 +394,10 @@ class Checklist(models.Model): price += self.commission_rub # Add commission of bottom-most category - category = self.category.get_ancestors(ascending=True, include_self=True).first() - category_commission = getattr(category, 'commission', 0) - price += category_commission * self.price_rub / 100 + if self.category: + category = self.category.get_ancestors(ascending=True, include_self=True).first() + category_commission = getattr(category, 'commission', 0) + price += category_commission * self.price_rub / 100 return max(0, math.ceil(price))