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入门9 条件语句
条件语句: if 条件为真: 执行语句块 (执行完结束不执行elif,else) elif 条件为真: 执行语句块 (执行完结束不执行else) else: 执行语句块 #coding:utf-8 # ...
- 玩转web之ligerui(一)---ligerGrid又一次指定url
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012116457/article/details/27109227 请珍惜小编劳动成果.该文章为小 ...
- 20165322 实验一 Java开发环境的熟悉
实验一 Java开发环境的熟悉 一.实验内容及步骤 (一)命令行下Java程序开发 按照步骤新建目录.键入代码,再编译运行输出.运行结果和TREE结构图如下: (二) IDEA下Java程序开发.调试 ...
- 课堂练习:HTML-----------一般标签、常用标签
[]练习:一般标签.常用标签 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...
- 活到老学到老:iOS开发中的基础知识(一)
本文参考 标哥的博客:宝库iOS开发笔试题 进行学习整理.与其说是看面试题,不如说是对自己知识的巩固.工欲善其事必先利其器,基础知识不牢固可能会导致编程中的一些注意不到的问题.总之一句话:活到老,学到 ...
- Hibernate的属性配置
Hibernate配置属性 hibernate.dialect Hibernate方言(Dialect)的类名 - 可以让Hibernate使用某些特定的数据库平台的特性 取值. full.class ...
- HTML5之canvas基本API介绍及应用 1
一.canvas的API: 1.颜色.样式和阴影: 2.线条样式属性和方法: 3.路径方法: 4.转换方法: 5.文本属性和方法: 6.像素操作方法和属性: 7.其他: drawImage:向画布上绘 ...
- 【题解】洛谷P2926 [USACO08DEC]拍头Patting Heads
洛谷P2926:https://www.luogu.org/problemnew/show/P2926 思路 对于每一个出现的数 从1到Max 凡是这个数的倍数 那么ans就加上他的个数 PS:最后要 ...
- CSS选择器种类及使用方法
css选择器 有通配符选择器书写格式:*+{声名块} 并集选择器/组合选择器 书写格式;元素或类或id+""+元素或类或id+","+元素或类或id{声明块} ...
- Python 学习笔记(七)Python字符串(四)
输入输出 输入函数 raw_input (Python3:input) >>> raw_input("请输入一个字母") #获取输入内容的一个函数 请输入一个字母 ...