27 lines
803 B
Python
27 lines
803 B
Python
from django.db import models
|
|
from apps.users.models import CustomUser
|
|
from apps.orders.models import Product
|
|
|
|
class ShoppingCar(models.Model):
|
|
user = models.ForeignKey(
|
|
CustomUser,
|
|
on_delete = models.CASCADE,
|
|
blank=True, null=True
|
|
)
|
|
item = models.ForeignKey(
|
|
Product,
|
|
on_delete = models.CASCADE
|
|
)
|
|
quantity = models.FloatField(default=1)
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
|
created_at = models.DateTimeField('created at', auto_now_add=True)
|
|
modified_at = models.DateTimeField('modified at', auto_now=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name = 'Carro de Producto'
|
|
verbose_name_plural = 'Carro de Productos'
|
|
ordering = ['-modified_at']
|