Fields Reference¶
All reactive fields extend their Django counterparts with reactive attributes.
Available fields¶
| Reactive field | Django base | Notes |
|---|---|---|
ReactiveCharField |
CharField |
|
ReactiveIntegerField |
IntegerField |
|
ReactiveFloatField |
FloatField |
|
ReactiveDecimalField |
DecimalField |
|
ReactiveBooleanField |
BooleanField |
|
ReactiveChoiceField |
ChoiceField |
Adds cascading support |
ReactiveMultipleChoiceField |
MultipleChoiceField |
|
ReactiveEmailField |
EmailField |
|
ReactiveURLField |
URLField |
|
ReactiveDateField |
DateField |
|
ReactiveDateTimeField |
DateTimeField |
|
ReactiveTimeField |
TimeField |
All standard Django field arguments (required, label, initial, help_text, widget, validators, etc.) work as usual.
Reactive attributes¶
These are the additional keyword arguments available on all reactive fields:
visible_when¶
-
Type:
str | NoneDatastar expression controlling field visibility. When it evaluates to
False, the field is hidden on the frontend and skipped during backend validation.
required_when¶
-
Type:
str | NoneDatastar expression for dynamic requirement. Evaluated on the backend — if
Trueand the field is empty, validation fails.
computed¶
-
Type:
str | NoneDatastar expression for computed value. The field becomes read-only on the frontend. On submit, the server recalculates the value from this expression.
depends_on¶
-
Type:
list[str] | NoneList of field names this field depends on. Used with
choices_fromonReactiveChoiceFieldfor cascading dropdowns.
disabled_when¶
-
Type:
str | NoneExpression to conditionally disable the field.
read_only_when¶
-
Type:
str | NoneExpression to conditionally make the field read-only.
help_text_when¶
-
Type:
dict[str, str] | NoneDict mapping expressions to help text strings. Only the matching help text is shown.
placeholder_when¶
-
Type:
dict[str, str] | NoneDict mapping expressions to placeholder strings.
min_when¶
-
Type:
dict[str, int | float] | NoneDict mapping expressions to minimum values.
max_when¶
-
Type:
dict[str, int | float] | NoneDict mapping expressions to maximum values.
ReactiveChoiceField extras¶
ReactiveChoiceField has additional attributes for declarative cascading:
| Attribute | Type | Default | Description |
|---|---|---|---|
choices_from |
Callable \| None |
None |
Callable returning objects for choices |
value_field |
str |
"pk" |
Attribute for option value |
label_field |
str \| None |
None |
Attribute for option label (default: str(obj)) |
label_template |
str \| None |
None |
Format string, e.g. "{name} (${price})" |
empty_choice |
str \| None |
None |
Label for empty option |
empty_choice_no_parent |
str \| None |
None |
Label when parent not selected |
Import¶
All fields are exported from the package root: