Django-Content-type用法
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用法的更多相关文章
- Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...
- Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Content Type相关timer jobs一键执行
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...
- 转载 SharePoint【Site Definition 系列】– 创建Content Type
转载原地址: http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...
- 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 ...
- 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 ...
- springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...
- .NET获取文件的MIME类型(Content Type)
第一种:这种获取MIME类型(Content Type)的方法需要在.NET 4.5之后才能够支持,但是非常简单. 优点:方便快捷 缺点:只能在.NET 4.5之后使用 public FileResu ...
- 万能的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 ...
随机推荐
- python入门8 输入输出
输入 input() 输出 print() #coding:utf-8 #/usr/bin/python """ 2018-11-03 dinghanhua 输入输出 & ...
- URL地址解析
URL的一般格式为(带方括号[]的为可选项): protocol :// hostname[:port] / path /[?query]#fragment 1.protocol :// 为传输协 ...
- PythonTip(1)
发现一个Python的题库,嘿嘿,练练手吧~~~ http://www.pythontip.com/ a + b 描述: 给你两个数a.b,请你计算它们的和,并输出. 例如: a = 3, b = 2 ...
- react中虚拟dom的diff算法
.state 数据 .jsx模板 .生成虚拟dom(虚拟DOM就是一个js对象,用它来描述真实DOM) ['div', {id:'abc'}, ['span', {}, 'hello world']] ...
- js数组、字符串常用方法
数组方面 push:向数组尾部增加内容,返回的是新数组的长度. var arr = [1,2,3]; console.log(arr); var b = arr.push(4); console.lo ...
- Intellij IDEA中Maven解决依赖失效
最近在折腾Maven和Sonatype的Nexus, 倒霉催的国内和公司网络... Nexus配合finalspeed或者kcptun倒是很给力, 但是Intellij就经常出问题, 出现红字也不动 ...
- Angularjs实例4
<!DOCTYPE html><html lang="zh-cn" ng-app=""><head><meta htt ...
- o'Reill的SVG精髓(第二版)学习笔记——第七章
第七章:路径 所有描述轮廓的数据都放在<path>元素的d属性中(d是data的缩写).路径数据包括单个字符的命令,比如M表示moveto,L表示lineto.接着是该命令的坐标信息. 7 ...
- ccenteros 部署 redis
step one : yum install redis -- 安装redis数据库 step two:安装完成之后开启redis 服务 service redis start syste ...
- 从$emit 到 父子组件通信 再到 eventBus
故事还是得从$emit说起,某一天翻文档的时候看到$emit的说明 触发当前实例上的事件?就是自身组件上的事件呗,在父子组件通信中,父组件通过props传递给子组件数据(高阶组件可以用provide和 ...