`
lishiguang
  • 浏览: 191552 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Django Models的数据类型 汇总

阅读更多

 

Django Models的数据类型

AutoField

 

IntegerField

BooleanField

true/false

 

CharField

maxlength,必填

 

TextField

 

 

CommaSeparatedIntegerField

maxlength,必填

逗号分隔

DateField

auto_now

可选,每次动作都会更新

auto_now _add

可选,一次产生

 

DateTimeField

auto_now

可选,每次动作都会更新

auto_now _add

可选,一次产生

 

EmailField

 

 

FileField

upload_to,可选

object.get_myfile_url

FilePathField

path

必填"/home/images"

match

可选,正则表达式,用于过滤文件名

recursive

可选,False,表示path的子目录是否包含在内

 

FloatField

max_digits

必填,数字长度

decimal_places

必填,即有效位数

 

 

ImageField

upload_to

 

height_field

可选

width_field

可选

需要验证,即Python Imaging Library

IntegerField

 

 

IPAddressField

 

 

NullBooleanField

 

相当于设置了null=TrueBooleanField

PhoneNumberField

 

美国电话号码格式

PositiveIntegerField

 

正整数字段

PositiveSmallIntegerField

 

小的正整数字段,取决于数据库特性

SlugField

maxlength(50)

可选

db_index

默认为True

prepopulate_from

可选,用于指示在admin表单中的可选值

短标签,仅包含字母、数字、下划线、连字符,一般用于url

SmallIntegerField

 

小整数字段,依赖于数据库特性

TimeField

auto_now

可选,每次动作都会更新

auto_now _add

可选,一次产生

 

URLField

verify_exists(True),检查URL可用性

 

USStateField

 

两个字母表示的美国州名字段

XMLField

schema_path,必选

 

 



 

感谢作者分享,转自 http://apps.hi.baidu.com/share/detail/21922174#content 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics