Base Field Class
All form fields inherit from the baseField class.
Whether the field is required. If
True, validation fails if field is empty.Widget instance to use for rendering. Each field has a default widget.
Human-readable label for the field. Auto-generated from field name if not provided.
Initial value for the field in unbound forms.
Help text to display with the field.
Dictionary of error codes to custom error messages.
Whether to render a hidden widget with the initial value.
List of additional validator functions to apply.
Whether to localize field input and output.
Whether the field is disabled (shown but not editable).
Suffix to append to the label. Overrides form-level setting.
Text Fields
CharField
Accepts text input.Maximum number of characters allowed.
Minimum number of characters required.
Whether to strip leading and trailing whitespace.
Value to return for empty input.
EmailField
Validates that input is a valid email address.EmailInputDefault max_length:
320 (per RFC 3696)
URLField
Validates that input is a valid URL.Scheme to prepend if none provided (e.g., “https”, “http”).
URLInput
SlugField
Validates input contains only letters, numbers, underscores, or hyphens.Whether to allow Unicode letters in addition to ASCII.
RegexField
Validates input against a regular expression.Regular expression string or compiled pattern object.
Numeric Fields
IntegerField
Validates that input is a valid integer.Maximum allowed value.
Minimum allowed value.
Value must be a multiple of this number.
NumberInput
FloatField
Validates that input is a valid floating-point number.NumberInput
DecimalField
Validates that input is a valid decimal number.Maximum number of total digits allowed.
Maximum number of decimal places allowed.
NumberInput
Date and Time Fields
DateField
Validates that input is a valid date.List of date format strings to accept (e.g.,
['%Y-%m-%d', '%m/%d/%Y']).DateInputReturns:
datetime.date object
TimeField
Validates that input is a valid time.TimeInputReturns:
datetime.time object
DateTimeField
Validates that input is a valid date and time.DateTimeInputReturns:
datetime.datetime object
DurationField
Validates that input is a valid duration."2 days", "1:30:00", "P3DT4H5M6S" (ISO 8601)Returns:
datetime.timedelta object
Choice Fields
ChoiceField
Validates that input is one of a set of valid choices.List of 2-tuples
(value, label) or nested groups.Select
TypedChoiceField
Like ChoiceField but coerces the value to a specific type.Function to coerce the value to the desired type.
Value to return for empty input.
MultipleChoiceField
Validates that input is one or more of valid choices.SelectMultipleReturns: List of strings
TypedMultipleChoiceField
Like MultipleChoiceField but coerces values to a specific type.Boolean Fields
BooleanField
Validates that input is boolean (checkbox).CheckboxInputReturns:
True or False
NullBooleanField
A boolean field that acceptsNone as a value.
NullBooleanSelectReturns:
True, False, or None
File Fields
FileField
Validates file upload.Maximum length of the filename.
Whether to allow empty files (0 bytes).
ClearableFileInputReturns:
UploadedFile object
ImageField
Validates that uploaded file is a valid image.Default widget:
ClearableFileInputReturns:
UploadedFile object with image validation
FilePathField
Allows selection of files from server filesystem.Absolute filesystem path to directory.
Regular expression pattern to filter filenames.
Whether to include subdirectories.
Whether to include files.
Whether to include folders.
Network Fields
GenericIPAddressField
Validates that input is a valid IP address.Protocol to validate:
"both", "ipv4", or "ipv6".Whether to unpack IPv4-mapped IPv6 addresses.
Special Fields
JSONField
Validates that input is valid JSON.Custom JSON encoder class.
Custom JSON decoder class.
TextareaReturns: Parsed JSON data (dict, list, etc.)
UUIDField
Validates that input is a valid UUID.uuid.UUID object
Composite Fields
ComboField
Validates input against multiple fields sequentially.List of Field instances to validate against.
MultiValueField
Aggregates multiple fields into a single field.List of Field instances.
Whether all sub-fields are required.
compress() method to combine field values.
SplitDateTimeField
Splits datetime input into separate date and time fields.SplitDateTimeWidgetReturns:
datetime.datetime object
Field Methods
All fields inherit these methods:clean()
ValidationError if invalid.
to_python()
validate()
run_validators()
has_changed()
True if data differs from initial value.