当前位置:   article > 正文

django 模型数据类型_django模型数据类型

django模型数据类型

数据模型类型

Model field reference | Django documentation | Django (djangoproject.com)

CharField —— 字符串

models.CharField(max_length=None, **options)
"""参数
max_length: 字符串长度
"""
  • 1
  • 2
  • 3
  • 4

FloatField —— 浮点数

models.FloatField(**options)
  • 1

IntegerField —— 整数

models.IntegerField(**options)
"""默认值
min_value: -2147483648 
max_value: 2147483647
"""
  • 1
  • 2
  • 3
  • 4
  • 5
AutoField —— 自增长
models.AutoField(**options)
"""默认值
min_value: 1
max_value: 2147483647
"""
  • 1
  • 2
  • 3
  • 4
  • 5
BigAutoField —— 大自增长
models.BigAutoField(**options)
"""默认值
min_value: 1
max_value: 9223372036854775807
"""
  • 1
  • 2
  • 3
  • 4
  • 5
BigIntegerField —— 大整数
models.BigIntegerField(**options)
"""默认值
min_value: -9223372036854775808
max_value: 9223372036854775807
"""
  • 1
  • 2
  • 3
  • 4
  • 5

BooleanField —— 布尔

models.BooleanField(**options)
  • 1

BinaryField —— 二进制

models.BinaryField(max_length=None, **options)
"""类型
bytes
bytearray
memoryview
"""
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

DateField —— 日期

models.DateField(auto_now=False, auto_now_add=False, **options)
"""类型
datetime.date
"""
  • 1
  • 2
  • 3
  • 4
DateTimeField —— 日期
models.DateTimeField(auto_now=False, auto_now_add=False, **options)
"""类型
datetime.datetime
"""
  • 1
  • 2
  • 3
  • 4

DecimalField —— 设置精度的十进制数

models.DecimalField(max_digits=None, decimal_places=None, **options)
"""参数
max_digits:数字允许的最大位数 
decimal_places:小数允许的最大位数
"""
  • 1
  • 2
  • 3
  • 4
  • 5

FileField —— 文件

models.FileField(upload_to=None, max_length=100, **options)
"""参数
upload_to: 文件上传位置,例如:uploads/%Y/%m/%d/
max_length: 文件名长度
"""
"""默认值
max_length: 100
"""
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/56535
推荐阅读
相关标签
  

闽ICP备14008679号