Replace 'parent' prefix filter with 'within' and 'within_include' #1380

Closed
opened 2025-12-29 16:31:56 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Nov 2, 2017).

Issue type

[x] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.2
  • NetBox version: 2.2.4

Description

The current parent search filter for the Prefix model executes the net_contained_or_equal queryset filter, which returns all prefixes contained by or equal to the given prefix. For example, ?parent=192.168.0.0/16 will return the prefix 192.168.0.0/16 as well as all of its children.

While working on #1676, the need for the ability to return only the children of a prefix became apparent. For example, we often want to edit or delete in bulk all the children of a prefix, but not the parent prefix itself. We can accommodate this by replacing the parent filter with two new filters:

  • ?within=192.0.2.0/24 - Returns on the child prefixes within 192.0.2.0/24
  • ?within_include=192.0.2.0/24 - Returns 192.0.2.0/24 as well as its children

The parent filter will be maintained on the Prefix model until v2.3.

Originally created by @jeremystretch on GitHub (Nov 2, 2017). ### Issue type [x] Feature request <!-- Requesting the implementation of a new feature --> [ ] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> ### Environment * Python version: 3.5.2 * NetBox version: 2.2.4 ### Description The current `parent` search filter for the Prefix model executes the `net_contained_or_equal` queryset filter, which returns all prefixes contained by or equal to the given prefix. For example, `?parent=192.168.0.0/16` will return the prefix 192.168.0.0/16 as well as all of its children. While working on #1676, the need for the ability to return _only_ the children of a prefix became apparent. For example, we often want to edit or delete in bulk all the children of a prefix, but not the parent prefix itself. We can accommodate this by replacing the `parent` filter with two new filters: * `?within=192.0.2.0/24` - Returns on the child prefixes within 192.0.2.0/24 * `?within_include=192.0.2.0/24` - Returns 192.0.2.0/24 as well as its children The `parent` filter will be maintained on the Prefix model until v2.3.
adam added the type: feature label 2025-12-29 16:31:56 +01:00
adam closed this issue 2025-12-29 16:31:56 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1380