I would like to use postgresql window functions like rank() and dense_rank in some queries that need to be done in Django. It works for me in raw SQL, but I'm not sure how to do it in ORM.
A simplified expression looks like this:
SELECT id, user_id, score, RANK() OVER(ORDER BY score DESC) AS rank FROM game_score WHERE ...
How do you do this in ORM?
At some point, I may also need to add a section: |
(we use Django 1.9 in Python 3 and already depend on the functions of django.contrib.postgres)
sql django postgresql orm
Bartvds
source share