DateField
Displays a date or a datetime in the admin locale.
showTime decides whether the time part is rendered; the schema turns it on for
format: "date-time". For a time-only value the dispatcher picks TimeField instead.
Example
<DateField source="created_at" showTime />
Props
On top of locales and showTime the component accepts the shared
field props.
| Name | Type | Default | Description |
|---|---|---|---|
source (required) | string | — | Name of the field on the record |
showTime | boolean | false | Appends the time part |
locales | string | admin locale | Locale used to format the value |
emptyText | string | — | Text shown when the value is empty |
The value never wraps — the component forces white-space: nowrap so a list column keeps one row
per record. options is not forwarded to the underlying React Admin field.
Schema mapping
type: "string" with format: "date" or format: "date-time":
{"name": "created_at", "type": "string", "format": "date-time", "sortable": true}
- Python
- Ruby
DRF's DateField / DateTimeField — that is, any models.DateField or models.DateTimeField —
map to the two formats:
class Order(models.Model):
placed_at = models.DateTimeField(auto_now_add=True)
delivery_on = models.DateField(null=True, blank=True)
See also
- DateInput and DateTimeInput — the form counterparts
- DateRangeInput — filtering a list by a date range