mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-01 05:16:26 -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
|
||||
* `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)
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
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.
|
||||
|
||||
```python
|
||||
region = ObjectVar(
|
||||
@ -195,15 +192,12 @@ region = ObjectVar(
|
||||
)
|
||||
site = ObjectVar(
|
||||
model=Site,
|
||||
filter_fields={
|
||||
'accessor': 'region_id',
|
||||
'field_name': 'region',
|
||||
query_params={
|
||||
'region_id': '$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
|
||||
|
||||
Similar to `ObjectVar`, but allows for the selection of multiple objects.
|
||||
|
Loading…
Reference in New Issue
Block a user