IntegerField

class IntegerField

A field that converts its input to an integer.

IntegerField(
    *,
    required: bool = True,
    default: Any = None,
    gt: int | float | None = None,
    gte: int | float | None = None,
    lt: int | float | None = None,
    lte: int | float | None = None,
    multiple_of: int | float | None = None,
    one_of: collections.abc.Iterable[typing.Any] | None = None,
    messages: dict[str, str] | None = None
)

Bases: NumberField

ArgumentDescription
required

Whether the field is required. Defaults to True.

default

Default value for the field. Can be a static value or a callable. Defaults to None.

gt

Value must be greater than this. Defaults to None.

gte

Value must be greater than or equal to this. Defaults to None.

lt

Value must be less than this. Defaults to None.

lte

Value must be less than or equal to this. Defaults to None.

multiple_of

Value must be a multiple of this. Defaults to None.

one_of

List of values that the field value must be one of. Defaults to None.

messages

Dictionary of error codes to custom error message templates. These override the default error messages for this specific field. Example: {"required": "This field cannot be empty"}.