DateField
class DateField
A field that converts its input to a datetime.date without timezone.
DateField(
format='%Y-%m-%d',
*,
required: bool = True,
default: Any = None,
after_date: datetime.date | str | None = None,
before_date: datetime.date | str | None = None,
past_date: bool = False,
future_date: bool = False,
offset: int | float = 0,
one_of: collections.abc.Iterable[typing.Any] | None = None,
messages: dict[str, str] | None = None,
_utcnow: datetime.datetime | None = None
)
Bases: Field
| Argument | Description |
|---|---|
format |
The format of the date string. Defaults to '%Y-%m-%d'. |
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. |
after_date |
A date that the field value must be after. Defaults to None. |
before_date |
A date that the field value must be before. Defaults to None. |
past_date |
Whether the date must be in the past. Defaults to False. |
future_date |
Whether the date must be in the future. Defaults to False. |
offset |
Timezone offset in hours (floats are allowed) for calculating "today" whenpast_date or future_date are used. Defaults to 0 (UTC timezone). |
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: . |