I got confuse with the model carts because there are two tables used Cart and CartItem. Can you tell me their purposes with an example, please? Because if the model was something like this then i understand
class Cart(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, on_delete=models.CASCADE)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)
class CartItem(models.Model):
cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
# line_item_total also i could not understand.
line_item_total = models.DecimalField(max_digits=10, decimal_places=2)
But you have used items twice both in Cart and Cart Items. In cart as M2M field and in CartItem as FK.
Sorry i could not understand. Can you please explain this?
I got confuse with the model carts because there are two tables used
CartandCartItem. Can you tell me their purposes with an example, please? Because if the model was something like this then i understandBut you have used items twice both in Cart and Cart Items. In cart as M2M field and in CartItem as FK.
Sorry i could not understand. Can you please explain this?