device.site.vlans.all() does not work with VLAN groups #11654

Closed
opened 2025-12-29 21:48:09 +01:00 by adam · 1 comment
Owner

Originally created by @misch42 on GitHub (Sep 26, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.4.1

Python Version

3.12

Steps to Reproduce

Create a VLAN group with the scope "site" and choose site "A".
Create two VLANs, i.e. 10 and 20.
Assign VLAN 10 direct to the site "A".
Assign VLAN 20 to the group that is assigned to site "A".

To get all VLANs in a config tamplate I use:
for vlan in device.site.vlans.all()

With the change to deprecate VLAN to site assignment I only get the VLAN 10, that is directly assigned to the site. BUT NOT the vlan that is assigned to the VLAN group assigned to the site.

so the template
{% for vlan in device.site.vlans.all() %} vlan {{ vlan.vid }} name {{ vlan.name }} {%- endfor %}

results in

vlan 10 name MANAGEMENT

but no VLAN 20 any more.

Any idea how to solve this?

Michael Schwartzkopff

Expected Behavior

netbox renders all vlans regardless of assigned to a site or assigned to a group that is assigned to a site.

Observed Behavior

netbox only renders VLANs directly assigned to the site. VLANs in the group are ignored.

Originally created by @misch42 on GitHub (Sep 26, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.4.1 ### Python Version 3.12 ### Steps to Reproduce Create a VLAN group with the scope "site" and choose site "A". Create two VLANs, i.e. 10 and 20. Assign VLAN 10 direct to the site "A". Assign VLAN 20 to the group that is assigned to site "A". To get all VLANs in a config tamplate I use: for vlan in device.site.vlans.all() With the change to deprecate VLAN to site assignment I only get the VLAN 10, that is directly assigned to the site. BUT NOT the vlan that is assigned to the VLAN group assigned to the site. so the template {% for vlan in device.site.vlans.all() %} vlan {{ vlan.vid }} name {{ vlan.name }} {%- endfor %} results in vlan 10 name MANAGEMENT but no VLAN 20 any more. Any idea how to solve this? Michael Schwartzkopff ### Expected Behavior netbox renders all vlans regardless of assigned to a site or assigned to a group that is assigned to a site. ### Observed Behavior netbox only renders VLANs directly assigned to the site. VLANs in the group are ignored.
adam added the netbox label 2025-12-29 21:48:09 +01:00
adam closed this issue 2025-12-29 21:48:09 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 29, 2025):

This is working as expected. site.vlans.all() is a low-level Django ORM query that returns only the VLANs which have been directly assigned to the site via the site ForeignKey (which is now deprecated; see #19738).

If you need assistance modifying the query in your template, please open a discussion instead.

@jeremystretch commented on GitHub (Sep 29, 2025): This is working as expected. `site.vlans.all()` is a low-level Django ORM query that returns only the VLANs which have been directly assigned to the site via the `site` ForeignKey (which is now deprecated; see #19738). If you need assistance modifying the query in your template, please open a discussion instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11654