from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericRelation,GenericForeignKey class SuperCourse(models.Model):
name = models.CharField(max_length=32,verbose_name="超级课名")
course_policy = GenericRelation('CoursePolicy') class NormalCourse(models.Model):
name = models.CharField(max_length=32,verbose_name='普通课名')
course_policy = GenericRelation('CoursePolicy') class CoursePolicy(models.Model):
price = models.IntegerField(verbose_name="价格")
period = models.IntegerField(verbose_name="周期")
object_id = models.IntegerField(verbose_name="课程id")
table_name = models.ForeignKey(ContentType,verbose_name="关键在ContentType表里面的表名")
# obj = GenericForeignKey('table_name',"object_id")
obj = GenericForeignKey(ct_field=table_name,fk_field=object_id)

  

Django-Content-type用法的更多相关文章

  1. Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...

  2. Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...

  3. SharePoint自动化系列——Add content type to list.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...

  4. SharePoint自动化系列——Content Type相关timer jobs一键执行

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...

  5. 转载 SharePoint【Site Definition 系列】– 创建Content Type

    转载原地址:  http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...

  6. the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header

    the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header ...

  7. Springs Element 'beans' cannot have character [children], because the type's content type is element-only

    Springs Element 'beans' cannot have character [children], because the type's content type is element ...

  8. springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...

  9. .NET获取文件的MIME类型(Content Type)

    第一种:这种获取MIME类型(Content Type)的方法需要在.NET 4.5之后才能够支持,但是非常简单. 优点:方便快捷 缺点:只能在.NET 4.5之后使用 public FileResu ...

  10. 万能的ctrl+shift+F(Element 'beans' cannot have character [children], because the type's content type is element-only.错误)

    今天在spring-servlet.xml文件中出现了一个莫名其妙的错误:Element 'beans' cannot have character [children], because the t ...

随机推荐

  1. python入门2 python字符串换行显示、字符串太长\连接多行

    #coding:utf-8 #/usr/bin/python """ 2018-11-03 dinghanhua 缩进 换行 """ &qu ...

  2. IOS 触摸事件的处理

    触摸事件的处理1.判断触摸点在谁身上: 调用所有UI控件的- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 2.pointIn ...

  3. 从零开始Vue项目实战(三)-项目结构

    目录结构 ├── README.md 项目介绍 ├── index.html 入口页面 ├── build 构建脚本目录 │ ├── build-server.js 运行本地构建服务器,可以访问构建后 ...

  4. [18/11/28]Java中的包(package)

    一.为何引入包? 包机制是Java中管理类的重要手段. 开发中,我们会遇到大量同名的类,通过包我们很容易对解决类重名的问题,也可以实现对类的有效管理. 包对于类,相当于文件夹对于文件的作用.(同一文件 ...

  5. 如何解决“请考虑使用 app.config 将程序集“XXXXXXXX”从版本XXXX重新映射到版本XXXX”的问题

    > 请考虑使用 app.config 将程序集“System.ValueTuple, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”从版本“\ ...

  6. 【luogu P1640 [SCOI2010]连续攻击游戏】 题解

    题目链接:https://www.luogu.org/problemnew/show/P1640 数据有点水吧,从属性值连向对应武器编号. 枚举属性值匹配,遇到第一个无法匹配的直接跳出就好惹~. #i ...

  7. 【luogu P3371 单源最短路径】 模板 dij + heap

    题目链接:https://www.luogu.org/problemnew/show/P3371#sub 堆优化迪杰斯特拉,留着以后复习用 #include <iostream> #inc ...

  8. swiper插件使用技巧

    1.加载插件: <!DOCTYPE html> <html> <head> ... <link rel="stylesheet" href ...

  9. Java虚拟机垃圾回收:基础点(转载)

    1.Java虚拟机垃圾回收 垃圾回收,或称垃圾收集(Garbage Collection,GC)是指自动管理回收不再被引用的内存数据. 在1960年诞生于MIT的Lisp语言首次使用了动态内存分配和垃 ...

  10. 小白袍 -- Chapter 1 Java中的Encode与Decode

    前几天做一个邮件发送功能,一些常用信息配置在properties文件中,通过prop.getProperty(key)来获取配置的信息,结果配置文件中是用中文写的,邮件发送成功后,邮箱中的激活链接是乱 ...