Order column

4 views
Skip to first unread message

Luca Bertolotti

unread,
Sep 18, 2019, 5:48:13 AM9/18/19
to Django users
Hello
I have a query that filter the data.
I put the results in a table in the template
I have make a function that by clkicking on the th order the data,ex.

def filter(request):

  results = My.objects.filter(........)

  return render(request, "pro/all.html", {"all": results, })


than in the template i have :
.........
<tr>
            <td><ID</td> <td><a href="/order/column_name">Column Name</td> <td><a href="/order/street">street</td> 
</tr>            
etx.......


than i have the def

def order(request, column_name)
   
   here i need to have again :
   results = My.objects.filter(........).order_by(........) 
So in which way i can pass the variable results in order to apply the order_by
Reply all
Reply to author
Forward
0 new messages