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为课程的数据