django 模型数据类型

文章目录

    • 数据模型类型
      • CharField —— 字符串
      • FloatField —— 浮点数
      • IntegerField —— 整数
        • AutoField —— 自增长
          • BigAutoField —— 大自增长
        • BigIntegerField —— 大整数
      • BooleanField —— 布尔
      • BinaryField —— 二进制
      • DateField —— 日期
        • DateTimeField —— 日期
      • DecimalField —— 设置精度的十进制数
      • FileField —— 文件

数据模型类型

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

CharField —— 字符串

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

FloatField —— 浮点数

models.FloatField(**options)

IntegerField —— 整数

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

BooleanField —— 布尔

models.BooleanField(**options)

BinaryField —— 二进制

models.BinaryField(max_length=None, **options)
"""类型
bytes
bytearray
memoryview
"""

DateField —— 日期

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

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

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

FileField —— 文件

models.FileField(upload_to=None, max_length=100, **options)
"""参数
upload_to: 文件上传位置,例如:uploads/%Y/%m/%d/
max_length: 文件名长度
"""
"""默认值
max_length: 100
"""

你可能感兴趣的:(Python,django,python,后端)