Skip to content

Include child locations in rack/device lists for location floorplans - #103

Open
bpapaylle wants to merge 1 commit into
netbox-community:mainfrom
bpapaylle:fix/location-descendants
Open

Include child locations in rack/device lists for location floorplans#103
bpapaylle wants to merge 1 commit into
netbox-community:mainfrom
bpapaylle:fix/location-descendants

Conversation

@bpapaylle

@bpapaylle bpapaylle commented Jul 14, 2026

Copy link
Copy Markdown

Problem

When a floorplan is attached to a parent location, the rack and device
pick-lists in the editor filter on an exact location match
(location=fp_instance.location.id). Racks are usually assigned to leaf
locations (rooms, rows), so a floorplan on the parent location offers
nothing to place.

Typical case: a datacenter location split into several room locations,
with every rack assigned to a room. The datacenter-level floorplan shows
an empty rack list, making a global datacenter view impossible.

Solution

Filter on the location's descendants instead of an exact match, in both
FloorplanRackListView and FloorplanDeviceListView:

location__in=fp_instance.location.get_descendants(include_self=True)

Location is a tree model, so get_descendants(include_self=True) is
available natively. Leaf locations keep the exact same behaviour as
before (include_self=True, no descendants), so this is strictly
additive: only parent-location floorplans gain the racks/devices of
their children.

Tested

On NetBox 5.0.1, with a parent location whose racks all live in child
locations: before the change, the parent-location floorplan offered no
racks at all; after, every rack from the child locations is offered,
and child-location floorplans behave exactly as before.

🤖 Generated with Claude Code

@bpapaylle
bpapaylle requested a review from cruse1977 as a code owner July 14, 2026 09:32
A floorplan attached to a parent location previously offered no racks or
devices to place when they are assigned to its child locations, which is
the common case for a datacenter location split into rooms/rows. Filter
on the location's descendants (including itself) instead of an exact
location match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bpapaylle
bpapaylle force-pushed the fix/location-descendants branch from 8a9976a to e149e69 Compare July 14, 2026 09:36
@cruse1977

Copy link
Copy Markdown
Member

Interesting tested on NetBox 5.0.1 - given that doesn't exist.

@bpapaylle

Copy link
Copy Markdown
Author

it's a typo my bad, it was tested on the following docker image netboxcommunity/netbox:v4.6.2-5.0.1, that is where the 5.0.1 is coming from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants