0

I do order by with request.GET.get('order_by',None)

but

Now I want to trade with more columns.

Ex: https://www.example.com/?order_by=col1&order_by=-col2

and I want to get values.

columns = request.GET.getlist('order_by')

Then,

References.objects.order_by(*columns)

How do I create the above URL?

I tried to add the values I received with Request.GET.get to the list, but it was unreasonable. Because the same columns were added again.

Mahmut Yakan
  • 53
  • 1
  • 7
  • Possible duplicate of [Handling Django request.GET and multiple variables for the same parameter name](https://stackoverflow.com/questions/3910165/handling-django-request-get-and-multiple-variables-for-the-same-parameter-name) – Endre Both Apr 12 '19 at 08:26
  • I'm not exactly sure what your question is here. – Daniel Roseman Apr 12 '19 at 08:28
  • I know this getlist but I just dont know get url. – Mahmut Yakan Apr 12 '19 at 08:33
  • I don't think you need to configure a url for accessing the get parameters. For detailed usage of urlconf and get parameters in url, you can refer to this post https://stackoverflow.com/questions/150505/capturing-url-parameters-in-request-get – Sanip Apr 12 '19 at 08:58
  • Well then I ask how I can do multiple order_by. When I click first column is sorted. Then same thing for second column. Changes should not be lost. It should be ordered in both columns. – Mahmut Yakan Apr 12 '19 at 09:21

0 Answers0