content type

content type 是Django提供的用来储存项目中所有app中的表名的表,每个项目都会自动生成该表
源码:
在这里插入图片描述
准备数据

在这里插入图片描述

没新建一个表,content_type中自动写入新建的表名

  • 创建优惠券对象
    在这里插入图片描述

  • 查看优惠券绑定了哪个对象
    在这里插入图片描述

  • 查看对象有多少优惠券
    在这里插入图片描述
    通过content_type 的model_class 可以拿到模型类,
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42233629/article/details/85177640