Jelajahi Sumber

Fixes #4791: Update custom script documentation for ObjectVar

Jeremy Stretch 5 tahun lalu
induk
melakukan
71afba4d2e
2 mengubah file dengan 8 tambahan dan 7 penghapusan
  1. 7 6
      docs/additional-features/custom-scripts.md
  2. 1 1
      netbox/extras/scripts.py

+ 7 - 6
docs/additional-features/custom-scripts.md

@@ -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(
-            manufacturer__name='Cisco',
-            model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T']
-        )
+        queryset = DeviceType.objects.all()
     )
     )
 
 
     def run(self, data, commit):
     def run(self, data, commit):

+ 1 - 1
netbox/extras/scripts.py

@@ -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