mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-01 21:36:25 -06:00
Revert changes from d0208d4
This commit is contained in:
parent
ba0ab6be46
commit
06871405b1
@ -171,7 +171,6 @@ A particular object within NetBox. Each ObjectVar must specify a particular mode
|
|||||||
|
|
||||||
* `model` - The model class
|
* `model` - The model class
|
||||||
* `query_params` - A dictionary of query parameters to use when retrieving available options (optional)
|
* `query_params` - A dictionary of query parameters to use when retrieving available options (optional)
|
||||||
* `filter_fields` - A dictionary or list of dictionaries that define a related field (optional)
|
|
||||||
* `null_option` - A label representing a "null" or empty choice (optional)
|
* `null_option` - A label representing a "null" or empty choice (optional)
|
||||||
|
|
||||||
To limit the selections available within the list, additional query parameters can be passed as the `query_params` dictionary. For example, to show only devices with an "active" status:
|
To limit the selections available within the list, additional query parameters can be passed as the `query_params` dictionary. For example, to show only devices with an "active" status:
|
||||||
@ -185,9 +184,7 @@ device = ObjectVar(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Multiple values can be specified by assigning a list to the dictionary key.
|
Multiple values can be specified by assigning a list to the dictionary key. It is also possible to reference the value of other fields in the form by prepending a dollar sign (`$`) to the variable's name.
|
||||||
|
|
||||||
It is also possible to reference the value of other fields in the form by using the `filter_fields` attribute. For example, to only show sites matching the selected region:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
region = ObjectVar(
|
region = ObjectVar(
|
||||||
@ -195,15 +192,12 @@ region = ObjectVar(
|
|||||||
)
|
)
|
||||||
site = ObjectVar(
|
site = ObjectVar(
|
||||||
model=Site,
|
model=Site,
|
||||||
filter_fields={
|
query_params={
|
||||||
'accessor': 'region_id',
|
'region_id': '$region'
|
||||||
'field_name': 'region',
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
In this example, `accessor` refers to the `region_id` field on the `Site` model, and `field_name` refers to form field name of the `Region` model.
|
|
||||||
|
|
||||||
### MultiObjectVar
|
### MultiObjectVar
|
||||||
|
|
||||||
Similar to `ObjectVar`, but allows for the selection of multiple objects.
|
Similar to `ObjectVar`, but allows for the selection of multiple objects.
|
||||||
|
Loading…
Reference in New Issue
Block a user