Comp-490-SeniorProject / site

MIT License
0 stars 1 forks source link

Add filters to viewsets #60

Closed MarkKoz closed 2 years ago

MarkKoz commented 2 years ago

This adds filtering capabilities to endpoints. Each endpoint has a set of fields by which filtering is permitted. This is a simple equality filter (i.e. the value given has to exactly match the value of the field).

For example, http://127.0.0.1:8000/api/tests/?device__id=2&name=test_01 returns tests named test_01 which are for the device with an ID of 2. To see all available fields for filtering, refer to the filterset_fields list in each viewset.

Some endpoints also have support for ordering. For example, http://127.0.0.1:8000/api/test_history/?ordering=started_at. This can be combined with filters. To see more information, refer to the docs. To see all available fields for ordering, refer to the ordering_fields in each viewset.