当前位置: 首页 > 编程日记 > 正文

Field types

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Field types

The generated Form class will have a form field for every model field. Each model field has a corresponding default form field. For example, a CharField on a model is represented as a CharField on a form. A model ManyToManyField is represented as aMultipleChoiceField. Here is the full list of conversions:

Model fieldForm field
AutoFieldNot represented in the form
BigIntegerFieldIntegerField with min_value set to -9223372036854775808 andmax_value set to 9223372036854775807.
BooleanFieldBooleanField
CharFieldCharField with max_length set to the model field's max_length
CommaSeparatedIntegerFieldCharField
DateFieldDateField
DateTimeFieldDateTimeField
DecimalFieldDecimalField
EmailFieldEmailField
FileFieldFileField
FilePathFieldCharField
FloatFieldFloatField
ForeignKeyModelChoiceField (see below)
ImageFieldImageField
IntegerFieldIntegerField
IPAddressFieldIPAddressField
ManyToManyFieldModelMultipleChoiceField (see below)
NullBooleanFieldCharField
PhoneNumberFieldUSPhoneNumberField (from django.contrib.localflavor.us)
PositiveIntegerFieldIntegerField
PositiveSmallIntegerFieldIntegerField
SlugFieldSlugField
SmallIntegerFieldIntegerField
TextFieldCharField with widget=forms.Textarea
TimeFieldTimeField
URLFieldURLField with verify_exists set to the model field's verify_exists
New in Django 1.2: The  BigIntegerField is new in Django 1.2.

As you might expect, the ForeignKey and ManyToManyField model field types are special cases:

  • ForeignKey is represented by django.forms.ModelChoiceField, which is a ChoiceField whose choices are a model QuerySet.
  • ManyToManyField is represented by django.forms.ModelMultipleChoiceField, which is a MultipleChoiceField whose choices are a model QuerySet.

In addition, each generated form field has attributes set as follows:

  • If the model field has blank=True, then required is set to False on the form field. Otherwise, required=True.
  • The form field's label is set to the verbose_name of the model field, with the first character capitalized.
  • The form field's help_text is set to the help_text of the model field.
  • If the model field has choices set, then the form field's widget will be set to Select, with choices coming from the model field's choices. The choices will normally include the blank choice which is selected by default. If the field is required, this forces the user to make a selection. The blank choice will not be included if the model field has blank=False and an explicitdefault value (the default value will be initially selected instead).

Finally, note that you can override the form field used for a given model field. See Overriding the default field types or widgetsbelow.

转载于:https://my.oschina.net/tenking/blog/29447

相关文章:

【51CTO学院三周年】我的职业生涯有贵人相助--小强老师

个人认为功能测试做到一定年限之后,自然会遇到职业生涯中最大瓶颈——转型。对此,我的经历是这样的。话说那还是两年前,在搜索某问题的时候发现了51CTO,从中看到了很多大牛的博文和视频课程,顿时感觉自己找到宝了&…

在.NET中实现彩色光标,动画光标和自定义光标

作者:孟宪会 微软MVPTest.cs using System;using System.Drawing;using System.Windows.Forms;using System.Runtime.InteropServices;using System.Reflection; namespace ColorCursor{ public class Form1 : System.Windows.Forms.Form { [DllImport("us…

magento模板区块--首页content区块

首页替换 自定义首页content内容 在cms-->>page 新建首页 在content 里加入 -------------------------- <div class"col-left side-col"> <p class"home-callout"><a href"{{store direct_url"apparel/shoes/womens/anash…

遮挡也能识别?地平线提出时序信息提升行人检测准确度|​CVPR 2020

来源 | 驭势科技行人检测作为计算机视觉领域最基本的主题之一&#xff0c;多年来被广泛研究。尽管最先进的行人检测器已在无遮挡行人上取得了超过 90% 的准确率&#xff0c;但在严重遮挡行人检测上依然无法达到满意的效果。究其根源&#xff0c;主要存在以下两个难点&#xff1…

通过响应式web设计,使本站支持手机浏览

2019独角兽企业重金招聘Python工程师标准>>> 2014-01-28 14:49:14 现在越来越多的人通过手机来上网&#xff0c;手机由于屏幕尺寸的原因&#xff0c;当浏览为PC端浏览器设计的网页的时候&#xff0c;往往会出现各种各样的问题。 糊涂僧的这个小博客也一样&#xff0…

在ASP.NET中跨页面实现多选

作者&#xff1a;孟宪会 微软MVP SelectMultiPages.aspx <% Page EnableViewState"true" CodeBehind"SelectMultiPages.aspx.cs" Language"c#" AutoEventWireup"false" Inherits"eMeng.Exam.SelectMultiPages" %><…

c#有多少种可能导致写文件失败?

1.路径中有非法字符 Path.GetInvalidPathChars() 2.文件名中有非法字符 Path.GetInvalidFileNameChars() 3.文件创建时&#xff0c;文件夹只读。 4.文件创建时&#xff0c;文件夹权限不足&#xff0c;如需要管理员权限。 5.文件创建时&#xff0c;文件夹不存在。 6.系统目录&am…

抖音、快手和直播行业的火爆究竟给了谁机会?

经常收到一些CSDN小伙伴的留言&#xff0c;反馈如下这样的困惑“短视频这么火爆&#xff0c;我该学些什么技术才能入行&#xff1f;”“我想从事音视频开发&#xff0c;该如何入门和进阶&#xff1f;真的像坊间传闻的那么难吗&#xff1f;”音视频的开发前景做一个不恰当的比喻…

android上line-height的问题

关于line-height大家应该非常熟悉了吧&#xff0c;就是用来做垂直居中的&#xff0c;屡试不爽&#xff0c;基本上没有什么问题&#xff0c;但是最近一个项目&#xff0c;测试提了一个bug&#xff0c;看图吧。 从别处窃的图&#xff0c;这个问题只有安卓上才能复现&#xff0c;做…

深入讲解 ASP+ 验证

Anthony Moore Microsoft Corporation 2000年10月简介 这篇文章详细讲解了 ASP 验证控件的工作方式。如果要生成其中包含验证控件的复杂页面&#xff0c;或是要扩展验证框架&#xff0c;建议您阅读本文。如果要学习使用验证控件&#xff0c;或是要决定是否使用验证控件&…

EditText和TextView出现中文、英文等string串的排版问题

默认EditText和TextView自动换行。如果在string中出现了中文字符&#xff0c;排版出现意外&#xff0c;如图所示&#xff1a; 这是因为软盘默认的是半角输入&#xff0c;而字母与数字的占位与汉字不同&#xff0c;所以在默认的情况下会出现如上的排版情况。 但是如果将默认的半…

阿里云蒋江伟:我们致力于为世界提供70%的算力 | 凌云时刻

导读&#xff1a;6月9日&#xff0c;2020阿里云峰会在云端召开&#xff0c;阿里巴巴合伙人、阿里云智能基础产品事业部高级研究员蒋江伟出席峰会并做了题为《新基建&#xff0c;新算力&#xff1a;阿里云基础设施算力全新升级》的重磅发布。&#xff08;以下内容为演讲实录&…

zabbix 微信报警( python 2.x )

python 2.x 微信报警脚本#!/usr/bin/python #_*_coding:utf-8 _*_ __author__ lvnianimport urllib,urllib2 import json import sysdef gettoken(corpid,corpsecret):gettoken_url https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid corpid &corpsecret corpsec…

利用 AssemblyAI 在 PyTorch 中建立端到端的语音识别模型

作者 | Comet译者 | 天道酬勤&#xff0c;责编 | Carol出品 | AI 科技大本营&#xff08;ID&#xff1a;rgznai100&#xff09;这篇文章是由AssemblyAI的机器学习研究工程师Michael Nguyen撰写的。AssemblyAI使用Comet记录、可视化和了解模型开发流程。深度学习通过引入端到端的…

PHP中的页面跳转

PHP页面跳转一、header()函数 点击按钮<input type"submit" name "submit" value"确定" /> 使用POST方式<form action"X.php" method"post"> X.php页面只做判断逻辑 处理完以后 <?php //isset函数 if…

Closure Compiler 使用

为什么80%的码农都做不了架构师&#xff1f;>>> 该项目首页&#xff1a;http://code.google.com/intl/zh-CN/closure/compiler/ 下载地址&#xff1a;http://closure-compiler.googlecode.com/files/compiler-latest.zip 下载后解压&#xff0c;即可看到compiler.j…

如何通过动态生成Html灵活实现DataGrid分类统计的界面显示功能

作者&#xff1a;未知 请作者速与本人联系步入 IT 业已经有几年的时间了 , 从最早接触 pb6.0 到现在 .Net 技术 , 计算机技术不论是从硬件还是软件都有巨大的进步 . 而中国程序员总体水平在世界上也是远远落后&#xff0c;其中缺乏完善的体系、必要的交流和程序员个人英雄主义…

Revit二次开发之“选择某一楼层的墙”

其实就是过滤器的用法。这里想要找到同一楼层中的风管&#xff0c;不可行。 要用&#xff1a;duct.ReferenceLevel//选择某一楼层上的墙[Transaction(TransactionMode.Manual)][Regeneration(RegenerationOption.Manual)]//[Journaling(JournalingMode.NoCommandData)]publiccl…

百变应用场景下,优酷基于图执行引擎的算法服务框架筑造之路!

作者| 阿里文娱高级专家 随方&#xff0c;阿里文娱开发专家 轩成责编 | 屠敏头图 | CSDN 下载自视觉中国背景在阿里的业务中&#xff0c;有广泛的算法应用场景&#xff0c;也沉淀了相关的算法应用平台和工具&#xff1a;基础的算法引擎部分&#xff0c;有成熟的召回和打分预估引…

Attach Volume 操作(Part II) - 每天5分钟玩转 OpenStack(54)

上一节我们讨论了 attach volume 操作中 cinder-api 的工作&#xff0c;本节讨论 cinder-volume 和 nova-compute 如何将 volume attach 到 Instance。cinder-volume 初始化 volume 的连接cinder-volume 接收到 initialize_connection 消息后&#xff0c;会通过 tgt 创建 targe…

关于DataGrid等控件中的自动编号

作者&#xff1a;未知 请作者速与本人联系序号内容1Taye2BOx3Glass4StarCraft一、正序A、AllowPagingFalse情况下<asp:DataGrid id"DataGrid1" runat"server"> <Columns> <asp:TemplateColumn> <ItemTemplate> …

45个优秀的国外电子商务网站设计实例

这篇文章与大家分享45个国外优秀的电子商务网站设计案例&#xff0c;希望能带给你灵感。对于电子商务网站来说&#xff0c;也许销售更多产品比漂亮的外观设计更重要&#xff0c;不过漂亮的东西总是能给用户留下深刻的印象&#xff0c;一起欣赏。 TALBOTS Free People Armani Ex…

曝光!十万开发者喜爱的顶级当红讲师

作为一枚后浪程序员&#xff0c;在互联网时代下我们拥有巨大优势&#xff1a;知识的时间空间界限被打破&#xff0c;让我们有机会学习到前沿技术知识。以往&#xff0c;大部分程序员都是是通过传统的博客文章、参与线下会议等形式来获取最新知识&#xff0c;而 CSDN 推出的在线…

连接centos7桌面方法

方法一&#xff1a; 第一步$sudo yum install tigervnc* 第二步$vncserver&#xff08;提示输入连接密码&#xff09; 第三步关防火墙或开5901..等端口 第四步vncview连接 方法二&#xff1a; 下载nomachine https://www.nomachine.com/download/linux&id1rpm &#xff0d;…

让“云”无处不在-Citrix Xenserver之一 环境搭建

让“云”无处不在-Citrix Xenserver 一、准备部署环境 马博峰 2011年8月 ——————————————————————————————————————— 一、Xenserver介绍 Citrix XenServer 是一个完整的服务器虚拟化平台&#xff0c;已针对 Windows 和 Linux 虚拟服务器…

DataGrid/DataList

很久以前就想写一些关于DataGrid/DataList的东西&#xff0c;但是一直以来&#xff0c;一方面自感所学未深&#xff0c;另一方面&#xff0c;总觉无从下笔&#xff0c;一拖再拖&#xff0c;离刚开始的念头已距一年有余。DataGrid/DataList在ASP.NET中的重要性&#xff0c;想必就…

京东姚霆:推理能力,正是多模态技术未来亟需突破的瓶颈!

受访者 | 姚霆&#xff0c;京东 AI 研究院算法科学家记者 | 夕颜来源 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;21 世纪&#xff0c;没有谁不知道电商&#xff0c;工资可以不发&#xff0c;但是每个月不网购几单&#xff0c;那是不可能的&#xff01;打开熟悉的购…

[转]C#网络编程(异步传输字符串) - Part.3

本文转自&#xff1a;http://www.tracefact.net/CSharp-Programming/Network-Programming-Part3.aspx 这篇文章我们将前进一大步&#xff0c;使用异步的方式来对服务端编程&#xff0c;以使它成为一个真正意义上的服务器&#xff1a;可以为多个客户端的多次请求服务。但是开始之…

【百度地图API】——如何用label制作简易的房产标签

摘要&#xff1a; 最近&#xff0c;API爱好者们纷纷说&#xff0c;自定义marker太复杂了&#xff01;不仅定义复杂&#xff0c;连所有的dom事件都要自己重新定义。有没有快速简易创建房产标签的方法呢&#xff1f; 答案当然是有的啦~ 我们可以利用label嘛&#xff01; --------…

李洪根关于[SQL]对于分页存储过程

作者&#xff1a;李洪根 微软MVP1。我个人认为最好的分页方法是: Selecttop10*fromtablewhereid>200写成存储过程,上面的语句要拼一下sql语句,要获得最后大于的哪一个ID号2。那个用游标的方式,只适合于小数据量的表,如果表在一万行以上,就差劲了你的存储过程还比不上NOT IN…