Skip to main content

SchemaRangeField

Displays a lower–upper pair as two values separated by a dash.

Each bound is rendered by SchemaField, so a numeric range formats as numbers and a date range as dates. An open bound shows -∞ or ∞.

Example​

<SchemaRangeField source="price_range" fields={priceRangeSchema.properties} />

Props​

NameTypeDefaultDescription
source (required)string—Name of the object holding the range on the record
fields (required)FieldSchema[]—Must contain exactly the entries named lower and upper
caution

The component throws when fields lacks a lower or an upper entry — the schema for a range field must expose both as properties.

In a list each bound is boxed to a fixed width so the dash stays aligned across rows, and an empty range renders a centered --.

Schema mapping​

type: "object" with format: "range" and two properties:

{"name": "price_range", "type": "object", "format": "range",
"properties": [
{"name": "lower", "type": "number"},
{"name": "upper", "type": "number"}
]}

A Postgres range field maps to format: "range"; the generator derives lower/upper from the range's base type:

from django.contrib.postgres.fields import DecimalRangeField


class Product(models.Model):
price_range = DecimalRangeField(null=True, blank=True)

See also​