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 ...
随机推荐
- JavaMail简单应用
版权声明:本文为博主原创文章,未经博主同意不得转载. --caicongyang https://blog.csdn.net/caicongyang/article/details/33731395 ...
- 【LOJ6041】「雅礼集训 2017 Day7」事情的相似度(用LCT维护SAM的parent树)
点此看题面 大致题意: 给你一个\(01\)串,每次询问前缀编号在一段区间内的两个前缀的最长公共后缀的长度. 离线存储询问 考虑将询问离线,按右端点大小用邻接表存下来(直接排序当然也可以啦). 这样的 ...
- T4Toolbox简单了解
使用T4模板,最令人喜欢的就是T4Toolbox了,他可以帮助我们生成多文件,并且直接包含在项目中. 环境:vs2017 T4代码高亮插件:Devart T4 Editor 插件地址:T4 Toolb ...
- C#基础 一(方法详解)
需要知道:类和方法的关系 方法和参数修饰符 自定义方法可以有或没有参数,也可以有或没有返回值.可以被各种关键字(static.virtual.public.new等)修饰以限制其行为. C#参数修饰符 ...
- Zabbix: Database Monitor Installation
1. Install ODBC MS SQL Connector On Zabbix Server https://support.zabbix.com/browse/ZBX-6839 ...
- repo配置与连接
repo是远程访问android源码的工具,和git一起使用. repo的远程安装经常被屏蔽,你懂得. sudo apt-get install curl 244 sudo apt-get - ...
- oracle官网下载教程
1.百度搜索oracle 也可以直接点击进入 oracle官网 或直接进入 下载页面 2.选择中文,看的更容易些 3.拉到最下面,选择所有下载和试用 4.选择数据库下载 5.点击下载对 ...
- Oracle中with关键字的使用
open p_cr1 for with sqla as (select d.*, (select c.STATICMONTH from ly_zg_jzfbtstatic c where c.ID = ...
- node-zookeeper-dubbo 和egg实现远程连接
基于js的node-zookeeper-dubbo 和egg实现远程连接服务 const nzd = require('node-zookeeper-dubbo'); const opt={ appl ...
- Linux分享笔记:系统状态检测命令小结
作为一名合格的运维人员,要能很好地了解Linux服务器,要能熟练查看Linux系统的运行状态.以下是常用到的Linux系统状态检测命令. 1. ifconfig:用于获取网卡配置与网络状态等信息.通常 ...