Django-content—type
Django包含一个contenttype应用,它可以追踪安装在你的Django项目里的所有的应用,并提供一个高层次的,通用的接口用于与你的模型进行交互 Contenttypes 的核心应用是ContentType 模型,存在于 django.contrib.contenttypes.models.ContentType。ContentType 的实例表示并存储你的项目当中安装的应用的信息,
并且每当新的模型安装时会自动创建新的 ContentType 实例。 Contenttypes 框架包含在django-admin startproject 创建的默认的INSTALLED_APPS 列表中,但如果你移除了它或者你手动创建 INSTALLED_APPS 列表,你可以通过添加
'django.contrib.contenttypes'到你的 INSTALLED_APPS 设置中来启用它。 每一个contenttype实例有两个字段,共同来唯一描述一个已经安装的模型
app_label:模型所在的应用名称,这个取自模型的app_label属性,并只包括应用的python导入路径的最后部分
model:模型的类的名称
from django.contrib.contenttypes.models import ContentType
user_type = ContentType.objects.get(app_label="auth",model="user")
print(user_type) <contenttypes:user>
user_type.model_class() <class 'django.contrib.auth.models.User'>
user_type.get(username="xxx") <user:xxx>
表结构:

表操作 增加:每次生成表的时候会自动创建 查找: 正向: 反向:
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 ...
随机推荐
- 浅谈Android反调试 之 PTRACE_TRACEME
反调试原理: 关于Ptrace: http://www.cnblogs.com/tangr206/articles/3094358.html ptrace函数 原型为: #include & ...
- [SDOI2013]直径 (树的直径,贪心)
题目链接 Solution 我们直接找到一条直径 \(s\),起点为 \(begin\),终点为 \(end\). 从前往后遍历点 \(u\) ,若子树中最大的距离与 \(dis(u,begin)\) ...
- jenkins配置本机JDK和maven环境
1.jenkins官网下下载jenkins的war包 2.安装jenkins,启动命令:java -jar jenkins.war 3.打开http://localhost:8080/ 4.点击系统 ...
- 当axios需要传送application/x-www-form-urlencoded格式参数的问题
我发送出去的数据发现后台接收不到,查找了一下原因,发现需要form-data的数据后台才可以获取到.于是改成了form-data格式,成功了,后台获取到数据了,有点小激动,但是随即发现发送的数据格式出 ...
- hdu 1979 剪枝暴搜
Fill the blanks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 2999 sg函数(简单博弈)
Stone Game, Why are you always there? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/ ...
- Linux System Programming 学习笔记(三) 标准缓冲I/O
1. partial block operations are inefficient. The operating system has to “fix up” your I/O by ensuri ...
- TSP 旅行商问题(状态压缩dp)
题意:有n个城市,有p条单向路径,连通n个城市,旅行商从0城市开始旅行,那么旅行完所有城市再次回到城市0至少需要旅行多长的路程. 思路:n较小的情况下可以使用状态压缩dp,设集合S代表还未经过的城市的 ...
- gridview中的相关事件操作
原文发布时间为:2008-07-27 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...
- windows下webrtc的编译 2016(转)
====================20160124更新============================= 推荐一个FQ工具,shadowsocks,是需要付费的,一年也才不到100块,移 ...