mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #8995: Enable arbitrary ordering of REST API results
This commit is contained in:
@@ -106,3 +106,23 @@ expression: `n`. Here is an example of a lookup expression on a foreign key, it
|
||||
```no-highlight
|
||||
GET /api/ipam/vlans/?group_id__n=3203
|
||||
```
|
||||
|
||||
## Ordering Objects
|
||||
|
||||
To order results by a particular field, include the `ordering` query parameter. For example, order the list of sites according to their facility values:
|
||||
|
||||
```no-highlight
|
||||
GET /api/dcim/sites/?ordering=facility
|
||||
```
|
||||
|
||||
To invert the ordering, prepend a hyphen to the field name:
|
||||
|
||||
```no-highlight
|
||||
GET /api/dcim/sites/?ordering=-facility
|
||||
```
|
||||
|
||||
Multiple fields can be specified by separating the field names with a comma. For example:
|
||||
|
||||
```no-highlight
|
||||
GET /api/dcim/sites/?ordering=facility,-name
|
||||
```
|
||||
|
Reference in New Issue
Block a user