You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add example showing how to order results. (#15627)
* add example showing how to order results.
This addresses issue 15622 by building off filtering example to
show how to order results on a named field.
* Apply suggestions from code review
---------
Co-authored-by: Frank Clements <[email protected]>
Co-authored-by: Jeremy Stretch <[email protected]>
Copy file name to clipboardExpand all lines: docs/integrations/rest-api.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,13 +85,19 @@ Each model generally has two views associated with it: a list view and a detail
85
85
*`/api/dcim/devices/` - List existing devices or create a new device
86
86
*`/api/dcim/devices/123/` - Retrieve, update, or delete the device with ID 123
87
87
88
-
Lists of objects can be filtered using a set of query parameters. For example, to find all interfaces belonging to the device with ID 123:
88
+
Lists of objects can be filtered and ordered using a set of query parameters. For example, to find all interfaces belonging to the device with ID 123:
89
89
90
90
```
91
91
GET /api/dcim/interfaces/?device_id=123
92
92
```
93
93
94
-
See the [filtering documentation](../reference/filtering.md) for more details.
94
+
An optional `ordering` parameter can be used to define how to sort the results. Building off the previous example, to sort all the interfaces in reverse order of creation (newest to oldest) for a device with ID 123:
95
+
96
+
```
97
+
GET /api/dcim/interfaces/?device_id=123&ordering=-created
98
+
```
99
+
100
+
See the [filtering documentation](../reference/filtering.md) for more details on topics related to filtering, ordering and lookup expressions.
0 commit comments