django - 供应商 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 网站
解决方案
推荐阅读
- html - 如何在堆叠图标内居中元素
- ios - 如何打开watchos的网址
- vue.js - 为什么像`beforeLeave`这样的过渡方法在nuxt中不起作用
- javascript - 使用 .closest() 比较最近的 id
- c - Linux C 套接字 - recvmsg - 获取源 ifindex
- python - 如何在整个音频文件上调用 librosa 函数?
- laravel - 从 laravel 关系表中获取所有值
- javascript - 从 Java 访问 Mozilla Rhino 中的 NativeSet 成员
- awk - 使用 Sed 或 Awk 进行数据转换 - 名称到标题
- javascript - 使用反应节点 nodemailer express 的电子邮件 api 不起作用