so I am getting this error in cmd when I try to make migrations. Here is my code:
from django.db import models
from shop.models import Product
class Cart(models.Model):
cart_id = models.CharField(max_length=250, blank = True)
date_added = models.DateField(auto_now_add = True)
class Meta:
db_table - 'Cart'
ordering = ['date_added']
def __str__(self):
return self.cart_id
class CartItem(models.Model):
product = models.ForeignKey(Product, on_delete = models.CASCADE)
cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
quantity = models.IntegerField()
class Meta:
db_table = 'CartItem'
def sub_total(self):
return self.product.price * self.quantity
def __str__(self):
return self.product
This is my models.py file.
Thanks for any help you can give.
If the table Cart exists, you should write
db_table = 'Cart'
Instead of
db_table - 'Cart'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With