zoukankan      html  css  js  c++  java
  • Content_type组件

    class  Arite(models.Model):
        title=models.CharField()
        autor=models.CharField()
    
    class News(models.Model):
        title = models.CharField()
        autor = models.CharField()
    
    class Good_and_bad(models.Model):
         id_good=models.CharField()
    
        object_id=models.PositiveIntegerField()
        content_type=models.ForeignKey(ContentType,on_delete=models.CASCADE)
    
        content_object=GenericForeignKey()  #不影响表创建
     
    Good_and_bad.objects.first().content_object  #比如:new_obj
    policy_list=GenericRelation("pricepolicy")#不会影响表,但是会可以反向查询,根据课程对象 拿到价格表的所有content_type为课程的数据
  • 相关阅读:
    数据库连接池
    一致性hash
    java 集合大家族
    linkedlist
    HashMap
    hashcode
    Job 逻辑执行图
    CDN
    网站缓存
    Mysql临时文件目录控制
  • 原文地址:https://www.cnblogs.com/xzqpy/p/11455119.html
Copyright © 2011-2022 走看看