Enable sorting REST API results #6268

Closed
opened 2025-12-29 19:38:46 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 29, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1.10

Feature type

New functionality

Proposed functionality

Allow users to specify a field by which the results of a REST API query should be ordered. For example:

GET /api/dcim/sites/?ordering=tenant

This seems easily feasible by adding DRF's built-in OrderingFilter to DEFAULT_FILTER_BACKENDS. We'll also need to define ordering_fields on each API view set.

Edit: This was first proposed in #3650.

Use case

Allows for more efficiently retrieving a set of objects in a particular order via the REST API.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Mar 29, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1.10 ### Feature type New functionality ### Proposed functionality Allow users to specify a field by which the results of a REST API query should be ordered. For example: ``` GET /api/dcim/sites/?ordering=tenant ``` This seems easily feasible by adding DRF's built-in [OrderingFilter](https://www.django-rest-framework.org/api-guide/filtering/#orderingfilter) to `DEFAULT_FILTER_BACKENDS`. We'll also need to define `ordering_fields` on each API view set. Edit: This was first proposed in #3650. ### Use case Allows for more efficiently retrieving a set of objects in a particular order via the REST API. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:38:46 +01:00
adam closed this issue 2025-12-29 19:38:47 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6268