Skip to main content

DateRangeInput

Collects a date range in a calendar popover, with the days between the bounds highlighted as you hover.

The dispatcher picks it over SchemaRangeInput when both bounds of a range field are dates — which is what makes it the default input for date filters in a list.

Pick a range in the calendar below: the first click sets the lower bound, the second the upper one, and hovering previews everything in between.

Example​

<DateRangeInput source="placed_at" label="Placed between" />

Props​

On top of locales the component accepts the shared input props.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record; the value is {lower, upper}
localesstringnavigator.languageLocale used to render the calendar and format the value
labelstring | ReactElement | falselabel from the schemafalse hides the label
helperTextstring | ReactElement | falsehelpText from the schemaText under the input

The first click sets the lower bound, the second the upper one; a reset button in the popover clears both. Either bound may stay empty — an open range is a valid value.

Schema mapping​

type: "object" with format: "range" whose properties are both dates:

{"name": "placed_at", "type": "object", "format": "range",
"properties": [
{"name": "lower", "type": "string", "format": "date"},
{"name": "upper", "type": "string", "format": "date"}
]}

A RangeFilter over a date field emits the range format, which is how a list gets a “placed between” filter:

from django_filters import rest_framework as filters


class OrderFilterSet(filters.FilterSet):
placed_at = filters.DateFromToRangeFilter()

class Meta:
model = Order
fields = ["placed_at", "status"]

See also​