mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
Fixes #4791: Update custom script documentation for ObjectVar
This commit is contained in:
parent
ed1717f858
commit
71afba4d2e
@ -156,9 +156,13 @@ direction = ChoiceVar(choices=CHOICES)
|
|||||||
|
|
||||||
### ObjectVar
|
### ObjectVar
|
||||||
|
|
||||||
A NetBox object. The list of available objects is defined by the queryset parameter. Each instance of this variable is limited to a single object type.
|
A NetBox object of a particular type, identified by the associated queryset. Most models will utilize the REST API to retrieve available options: Note that any filtering on the queryset in this case has no effect.
|
||||||
|
|
||||||
* `queryset` - A [Django queryset](https://docs.djangoproject.com/en/stable/topics/db/queries/)
|
* `queryset` - The base [Django queryset](https://docs.djangoproject.com/en/stable/topics/db/queries/) for the model
|
||||||
|
|
||||||
|
### MultiObjectVar
|
||||||
|
|
||||||
|
Similar to `ObjectVar`, but allows for the selection of multiple objects.
|
||||||
|
|
||||||
### FileVar
|
### FileVar
|
||||||
|
|
||||||
@ -222,10 +226,7 @@ class NewBranchScript(Script):
|
|||||||
)
|
)
|
||||||
switch_model = ObjectVar(
|
switch_model = ObjectVar(
|
||||||
description="Access switch model",
|
description="Access switch model",
|
||||||
queryset = DeviceType.objects.filter(
|
queryset = DeviceType.objects.all()
|
||||||
manufacturer__name='Cisco',
|
|
||||||
model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T']
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self, data, commit):
|
def run(self, data, commit):
|
||||||
|
@ -167,7 +167,7 @@ class ChoiceVar(ScriptVariable):
|
|||||||
|
|
||||||
class ObjectVar(ScriptVariable):
|
class ObjectVar(ScriptVariable):
|
||||||
"""
|
"""
|
||||||
NetBox object representation. The provided QuerySet will determine the choices available.
|
A single object within NetBox.
|
||||||
"""
|
"""
|
||||||
form_field = DynamicModelChoiceField
|
form_field = DynamicModelChoiceField
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user