Sorting¶
Use the sort query parameter.
Single field¶
Multiple fields¶
Descending¶
import httpx
response = httpx.get("http://localhost:8000/api/customers", params={"sort": "-name,created_at"})
print(response.json())
Relationship path sorting¶
Practical examples¶
- Newest-first customers:
GET /customers?sort=-id - Owner then serial:
GET /computers?sort=owner.name,serial