首页 > 解决方案 > 供应商 ID 在电子商务应用程序 Django 中的放置位置

问题描述

class Product(models.Model):
    title           = models.CharField(max_length =120)
    slug            = models.SlugField(blank=True)
    description     = models.TextField()
    price           = models.DecimalField(decimal_places=2, max_digits=20, default=39.99)
    image           = models.ImageField(upload_to=upload_image_path,null=True, blank=True)
    featured        = models.BooleanField(default=False)
    active          = models.BooleanField(default=True)
    timestamp       = models.DateTimeField(auto_now_add=True)


class OrderItem(models.Model):
    item = models.ForeignKey(Product, on_delete=models.CASCADE)
    quantity = models.IntegerField(default=1)
    item_cart = models.CharField(max_length=20, null=True, blank=True)

class Cart(models.Model):
    user        = models.ForeignKey(User,null=True, blank=True,on_delete=models.CASCADE)
    products    = models.ManyToManyField(OrderItem, blank=True)
    subtotal    = models.DecimalField(default=0.00, max_digits=100, decimal_places=2)
    total       = models.DecimalField(default=0.00,max_digits=100,decimal_places=2)
    updated     = models.DateTimeField(auto_now=True)
    timestamp   = models.DateTimeField(auto_now_add=True)

在此模型中放置供应商 ID 的位置以及如何使用此数据模型为许多商店实施我为单个商店使用此数据模型制作了 ecom 网站

标签: djangodjango-modelsdjango-views

解决方案


推荐阅读