1024programmer Java DjangoORM field collection

DjangoORM field collection

AutoField(Field)
– int auto-increment column, the parameter primary_key=True must be filled in

BigAutoField(AutoField)
– bigint auto-increment column, the parameter primary_key=True must be filled in

Note: If there is no auto-increment column in the model, a column named id will automatically be created
from django.db import models

class UserInfo(models.Model):
# Automatically create an integer column named id that is incrementing
username = models.CharField(max_length=32)

class Group(models.Model):
# Customize the auto-increment column
nid = models.AutoField(primary_key=True)
name = models.CharField(max_length=32)

SmallIntegerField(IntegerField):
– Small integer -32768 ~ 32767

PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField)
– Positive small integer 0 ~ 32767
IntegerField(Field)
– Integer column (signed) -2147483648 ~ 2147483647

PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField)
– Positive integer 0 ~ 2147483647

BigIntegerField(IntegerField):
– Long integer (signed) -9223372036854775808 ~ 9223372036854775807

BooleanField(Field)
– Boolean value type

NullBooleanField(Field):
– A nullable Boolean value

CharField(Field)
– Character type
– The max_length parameter must be provided, max_length represents the character length

TextField(Field)
– Text type

EmailField(CharField):
– String type, validation mechanism provided in Django Admin and ModelForm

IPAddressField(Field)
– String type, provides verification IPV4 mechanism in Django Admin and ModelForm

GenericIPAddressField(Field)
– String type, verification Ipv4 and Ipv6 are provided in Django Admin and ModelForm
– Parameters:
protocol, used to specify Ipv4 or Ipv6, ‘both’, “ipv4″ ,”ipv6”
unpack_ipv4, if specified as True, when input::ffff:192.0.2.1, it can be resolved to 192.0.2.1. To enable this function, protocol=”both”

URLField(CharField)
– String type, validation URL provided in Django Admin and ModelForm

SlugField(CharField)
– String type, validation support is provided in Django Admin and ModelForm. Letters, numbers, underscores, connectors (minus sign)

CommaSeparatedIntegerField(CharField)
– String type, the format must be comma-separated numbers

UUIDField(Field)
– String type, verification of UUID format is provided in Django Admin and ModelForm

FilePathField(Field)
– String, Django Admin and ModelForm provide the function of reading files in a folder
– Parameters:
path, folder path
match=None, regular Match
recursive=False, recurse the following folders
allow_files=True, allow files
allow_folders=False, allow folders

FileField(Field)
– String, the path is saved in the database, and the file is uploaded to the specified directory
– Parameter:
upload_to = “” The saving path of the uploaded file
storage = None storage component , default django.core.files.storage.FileSystemStorage

ImageField(FileField)
– String, the path is saved in the database, and the file is uploaded to the specified directory
– Parameter:
upload_to = “” The saving path of the uploaded file
storage = None storage component , the default is django.core.files.storage.FileSystemStorage
width_field=None, the name of the database field saved in the height of the uploaded image (string)
height_field=None the name of the database field saved in the width of the uploaded image (string)

DateTimeField(DateField)
– date + time format YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]

DateField(DateTimeCheckMixin, Field)
– date format YYYY-MM-DD

TimeField(DateTimeCheckMixin, Field)
– Time format HH:MM[:ss[.uuuuuu]]

DurationField(Field)
– long integer, time interval, stored in the database as bigint, the value obtained in the ORM is datetime.timedelta type

FloatField(Field)
– floating point type

DecimalField(Field)
– Decimal decimal
– Parameters:
max_digits, total length of decimals
decimal_places, length of decimal places

BinaryField(Field)
– Binary type

Field collection

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/749433

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索