Skip to content

Allow MultiObjectVar to accept PKs higher than 9 when script is called with a single URL param #9430

@jsenecal

Description

@jsenecal

NetBox version

v3.2.3

Python version

3.9

Steps to Reproduce

  1. Start with a clean, empty installation
  2. Create a custom script testscript.py:
from extras.scripts import *
from dcim.models import Device

class MultiObjectVarTest(Script):
    devices = MultiObjectVar (model=Device)

    def run(data, commit):
        pass
  1. Create a dummy Manufacturer and DeviceType
  2. Fill the database with multiple Device objects (more than 10)
  3. Confirm that devices have at least picked up PKs 1 thru 10
  4. Access http://netbox/extras/scripts/testscript.MultiObjectVarTest/?devices=1 (1 is a valid, existing device pk) -> Confirm that the devices field is properly populated with the Device which has pk 1
  5. Access http://netbox/extras/scripts/testscript.MultiObjectVarTest/?devices=10 (10 is also a valid, existing device pk) -> Notice that the devices field is now empty

Expected Behavior

Access http://netbox/extras/scripts/testscript.MultiObjectVarTest/?devices=10 (10 is a valid, existing device pk) and confirm that the devices field is properly populated with the Device which has pk 10

Observed Behavior

The devices field is not populated with the Device which has PK 10, but can be searched manually.

I believe that this is due to the widget only prefetching the first few items and not knowing what to do with higher-count objects.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions