商品分类

class GoodsType(models.Model):

id = models.AutoField(primary_key=True)  # 分类id
name = models.CharField(max_length=30)  # 分类名称

class Meta:
    db_table = "t_goodsType"

class GoodsInfo(models.Model):

id = models.AutoField(primary_key=True)  # id
type = models.ForeignKey("GoodsType", verbose_name="商品种类",on_delete=models.CASCADE)
goods_sn = models.CharField(max_length=30, verbose_name="商品编号")  # 商品编号
goods_name = models.CharField(max_length=30, verbose_name="商品名称")  # 商品名称
# goods_img #商品图片
goods_img = models.ImageField(upload_to='upload/goods/img/', storage=ImageStorage(), verbose_name="商品图片")
brief = models.CharField(max_length=30, verbose_name="商品简介")  # 商品简介
unit = models.CharField(max_length=30, verbose_name="商品单位")  # 商品单位
bid = models.CharField(max_length=30, verbose_name="进价")  # 进价
price = models.CharField(max_length=30, verbose_name="售价")  # 售价
stock = models.IntegerField(default=1, verbose_name="商品库存")
status = models.SmallIntegerField(default=1, choices=((0, "线下"), (1, "上线")), verbose_name="商品状态")

class Meta:
    db_table = "t_goods"

1.基本逻辑
Snipaste_2020-04-26_01-25-48.png

2.商品添加
无标题.png

3.配置路由
Snipaste_2020-04-26_02-04-46.png

4.商品列表
Snipaste_2020-04-26_02-04-26.png


tahirjan
31 声望0 粉丝