Fix the DeviceType filtering example in Custom Scripts #3558

Closed
opened 2025-12-29 18:29:52 +01:00 by adam · 1 comment
Owner

Originally created by @markkuleinio on GitHub (Apr 10, 2020).

Change Type

[ ] Addition
[X] Correction
[ ] Deprecation
[ ] Cleanup (formatting, typos, etc.)

Area

[ ] Installation instructions
[ ] Configuration parameters
[X] Functionality/features
[ ] REST API
[ ] Administration/development
[ ] Other

Proposed Changes

The object filtering example does not work in Custom Scripts (the device list stays empty even though the device models exist in NetBox, tested with NetBox 2.7.11):

    switch_model = ObjectVar(
        description="Access switch model",
        queryset = DeviceType.objects.filter(
            manufacturer__name='Cisco',
            model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T']
        )
    )

I propose updating the example with a working code.

In #4453 there is a mention about APISelect but I cannot figure out the correct filtering use of it to submit a PR on this.

Originally created by @markkuleinio on GitHub (Apr 10, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. Please indicate the nature of the change by placing an X in one of the boxes below. --> ### Change Type [ ] Addition [X] Correction [ ] Deprecation [ ] Cleanup (formatting, typos, etc.) ### Area [ ] Installation instructions [ ] Configuration parameters [X] Functionality/features [ ] REST API [ ] Administration/development [ ] Other <!-- Describe the proposed change(s). --> ### Proposed Changes The object filtering example does not work in [Custom Scripts](https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/) (the device list stays empty even though the device models exist in NetBox, tested with NetBox 2.7.11): ``` switch_model = ObjectVar( description="Access switch model", queryset = DeviceType.objects.filter( manufacturer__name='Cisco', model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T'] ) ) ``` I propose updating the example with a working code. In #4453 there is a mention about `APISelect` but I cannot figure out the correct filtering use of it to submit a PR on this.
adam added the status: duplicate label 2025-12-29 18:29:52 +01:00
adam closed this issue 2025-12-29 18:29:52 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 10, 2020):

This looks to be essentially the same issue reported under #4463, and should be resolved by the same work. Going to mark it as a duplicate.

@jeremystretch commented on GitHub (Apr 10, 2020): This looks to be essentially the same issue reported under #4463, and should be resolved by the same work. Going to mark it as a duplicate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3558