Skip to main content

Field Reference

Complete reference of all field types, their SQL types, and Python types.

Integer Fields

FieldSQL TypePython TypeExtra Kwargs
AutoFieldSERIALint
BigAutoFieldBIGSERIALint
SmallAutoFieldSMALLSERIALint
IntFieldINTEGERintmin_value, max_value
SmallIntFieldSMALLINTintmin_value, max_value
BigIntFieldBIGINTintmin_value, max_value
PositiveIntFieldINTEGERintimplicit min_value=0

Text Fields

FieldSQL TypePython TypeExtra Kwargs
CharFieldVARCHAR(n)strmax_length, min_length, strip
TextFieldTEXTstrmin_length
EmailFieldVARCHAR(254)strauto email validation
SlugFieldVARCHAR(50)strauto slug validation
URLFieldVARCHAR(200)strauto URL validation
IPAddressFieldVARCHAR(15)strauto IPv4 validation

Date & Time Fields

FieldSQL TypePython TypeExtra Kwargs
DateFieldDATEdateauto_now, auto_now_add
DateTimeFieldTIMESTAMPdatetimeauto_now, auto_now_add
TimeFieldTIMEtime
DurationFieldBIGINTtimedeltastored as microseconds

Special Fields

FieldSQL TypePython TypeExtra Kwargs
BooleanFieldBOOLEANbool
NullBooleanFieldBOOLEANbool | Noneimplicit null=True
FloatFieldDOUBLE PRECISIONfloatmin_value, max_value
DecimalFieldNUMERIC(p,s)Decimalmax_digits, decimal_places
UUIDFieldUUIDUUIDauto_create
JSONFieldJSONBdict | list
BinaryFieldBYTEAbytes
ArrayFieldT[]listbase_field

Relationship Fields

FieldSQL TypePython TypeExtra Kwargs
ForeignKeyINTEGERinton_delete, related_name
OneToOneFieldINTEGER UNIQUEintsame as FK
ManyToManyField(join table)through

Common Field Options

CharField(
max_length=200, # Required for CharField
min_length=5, # Optional minimum
null=True, # Allow NULL in DB
blank=True, # Allow empty in validation
default="", # Default value or callable
unique=True, # UNIQUE constraint
db_index=True, # CREATE INDEX
choices=["a", "b"], # Restrict values
validators=[...], # Extra validators
editable=True, # Include in save()
help_text="...", # Documentation
verbose_name="...", # Human-readable label
db_column="col", # Override column name
primary_key=False, # Make this the PK
)