Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
Django ORM - get() with order_by()

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.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

How about

Model.objects.filter(some=condition).order_by('name').first()
about 4 years ago · Santiago Trujillo Report

0

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

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!