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 ...
随机推荐
- 用SVGDeveloper制作svg地图
项目中需要实现巴蜀地区图,并且将其分为川东.川西.川南.川北四个区域,鼠标悬浮对应区域的区块改变颜色.经过网上查询资料,并未找到现成的区域图,于是就利用SVGDeveloper工具绘制. 一.绘制地图 ...
- 关于sudo dpkg-divert –local –rename –add /sbin/initctl导致的开机无图标解决方法
背景: ubutnu16.04 使用status docker,发现 无法连接到 status: Unable to connect to Upstart: Failed to connect to ...
- jenkins发送html测试报告
jenkins发送html测试报告 https://blog.csdn.net/galen2016/article/details/77975965/ <!DOCTYPE html> & ...
- 推荐个PMP的内容,广州有需要的朋友可以参考看看
慧翔天地PMP®培训机构简介 广州慧翔企业管理咨询有限公司注册于2012年8月14日,注册资金200万元人民币.实际上从2011年就已经开始从事PMP推广及教学工作(2010年曾代理智鼎东方华南市场, ...
- SpringBoot重点详解--使用Junit进行单元测试
目录 添加依赖与配置 ApplicationContext测试 Environment测试 MockBean测试 Controller测试 情况一 情况二 方法一 方法二 本文将对在Springboo ...
- hdu 4301 dp
Divide Chocolate Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 古代猪文 BZOJ 1951
古代猪文 [问题描述] “在那山的那边海的那边有一群小肥猪.他们活泼又聪明,他们调皮又灵敏.他们自由自在生活在那绿色的大草坪,他们善良勇敢相互都关心……” ——选自猪王国民歌 很久很久以前,在山的那边 ...
- BZOJ——2134: 单选错位
http://www.lydsy.com/JudgeOnline/problem.php?id=2134 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: ...
- Xamarin.Forms的ActivityIndicator和ProgressBar比较
Xamarin.Forms的ActivityIndicator和ProgressBar比较 在Xamarin.Forms中,控件ActivityIndicator和ProgressBar都用来表示 ...
- awk在企业中最常用的语句
awk最常用以及面试基本都会被问到的实例: A.统计日志中每个URL被访问的次数 cat access.log http://www.etiantian.org/1.html http://post. ...