1

I've got a question. How to manage to change ordering thru the swagger. For example I've got a Menu model with fields: name and dishes. By GET I retrieve a list of menus and I would like to be able to choose in swagger if queryset should be ordered by name (alphabetically) or ordered by the numbers of dishes in menu (descending).

I managed to do something similar with filtering the queryset: enter image description here But I can't find solution for switching the ordering.

  • Does this answer your question? [Capturing URL parameters in request.GET](https://stackoverflow.com/questions/150505/capturing-url-parameters-in-request-get) – martin8768 Feb 24 '23 at 13:50

1 Answers1

0

Take a look at how Django REST Framework does it, you can use HTTP query parameters localhost:8000/page?order_by=name. Take a look at the QueryDict API and this other StackOverflow question as it's really similar.

martin8768
  • 565
  • 5
  • 20