name = models.CharField('类别名',default="", max_length=30,help_text="类别名")
birthday = models.DateField("出生年月",null=True, blank=True)
category = models.ForeignKey(GoodsCategory, on_delete=models.CASCADE, verbose_name="商品类目")
goods = models.ForeignKey(Goods, on_delete=models.CASCADE, verbose_name="商品", related_name="images")
class Meta:
verbose_name = '商品轮播'
verbose_name_plural = verbose_name
def __str__(self):
return self.goods.name
add_time = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
# get_user_model方法会去setting中找AUTH_USER_MODEL
from django.contrib.auth import get_user_model
User = get_user_model()
order_sn = models.CharField("订单编号",max_length=30, null=True, blank=True, unique=True)
class Meta:
verbose_name = '用户收藏'
verbose_name_plural = verbose_name
unique_together = ("user", "goods")
"OPTIONS":{"init_command":"SET default_storage_engine=INNODB;"