I want a mix of get() and order_by() like this
Model.objects.get(some=condition).order_by('name')
I want a single result (not filter) and ordered by name at the same time.
How about
Model.objects.filter(some=condition).order_by('name').first()
get() wont take order_by() as get only returns one single object and you cannot order by one one row.
and for order by you need multiple rows for the ordering. use filter('your where clause').order_by('asc/desc')
hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With