from django.db import models
from django.db.models import Sum, F
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _


class Cart(models.Model):
    owner = models.OneToOneField(to='accounts.User', on_delete=models.
        SET_NULL, null=True, related_name='cart')

    @cached_property
    def total_cost(self):
        return self.items.aggregate(total_cost=Sum(F('quantity') * F(
            'product__price'), output_field=models.CharField()))['total_cost']


class CartItem(models.Model):
    product = models.ForeignKey(to='products.Product', on_delete=models.
        CASCADE, related_name='CartItem')
    cart = models.ForeignKey(to='cart.Cart', on_delete=models.CASCADE,
        related_name='items')
    quantity = models.IntegerField()
    order = models.PositiveSmallIntegerField(verbose_name=_('Order'))
    active = models.BooleanField(default=True)

91ccccebdd05418862d37f9ae7f3b3943765abc5
<mask token>


class Cart(models.Model):
    <mask token>
    <mask token>


class CartItem(models.Model):
    product = models.ForeignKey(to='products.Product', on_delete=models.
        CASCADE, related_name='CartItem')
    cart = models.ForeignKey(to='cart.Cart', on_delete=models.CASCADE,
        related_name='items')
    quantity = models.IntegerField()
    order = models.PositiveSmallIntegerField(verbose_name=_('Order'))
    active = models.BooleanField(default=True)

<mask token>


class Cart(models.Model):
    <mask token>

    @cached_property
    def total_cost(self):
        return self.items.aggregate(total_cost=Sum(F('quantity') * F(
            'product__price'), output_field=models.CharField()))['total_cost']


class CartItem(models.Model):
    product = models.ForeignKey(to='products.Product', on_delete=models.
        CASCADE, related_name='CartItem')
    cart = models.ForeignKey(to='cart.Cart', on_delete=models.CASCADE,
        related_name='items')
    quantity = models.IntegerField()
    order = models.PositiveSmallIntegerField(verbose_name=_('Order'))
    active = models.BooleanField(default=True)

<mask token>


class Cart(models.Model):
    owner = models.OneToOneField(to='accounts.User', on_delete=models.
        SET_NULL, null=True, related_name='cart')

    @cached_property
    def total_cost(self):
        return self.items.aggregate(total_cost=Sum(F('quantity') * F(
            'product__price'), output_field=models.CharField()))['total_cost']


class CartItem(models.Model):
    product = models.ForeignKey(to='products.Product', on_delete=models.
        CASCADE, related_name='CartItem')
    cart = models.ForeignKey(to='cart.Cart', on_delete=models.CASCADE,
        related_name='items')
    quantity = models.IntegerField()
    order = models.PositiveSmallIntegerField(verbose_name=_('Order'))
    active = models.BooleanField(default=True)

from django.db import models
from django.db.models import Sum, F
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _


class Cart(models.Model):
    owner = models.OneToOneField(to='accounts.User', on_delete=models.
        SET_NULL, null=True, related_name='cart')

    @cached_property
    def total_cost(self):
        return self.items.aggregate(total_cost=Sum(F('quantity') * F(
            'product__price'), output_field=models.CharField()))['total_cost']


class CartItem(models.Model):
    product = models.ForeignKey(to='products.Product', on_delete=models.
        CASCADE, related_name='CartItem')
    cart = models.ForeignKey(to='cart.Cart', on_delete=models.CASCADE,
        related_name='items')
    quantity = models.IntegerField()
    order = models.PositiveSmallIntegerField(verbose_name=_('Order'))
    active = models.BooleanField(default=True)
