Using django and django-voting app, how can I order a queryset according to the votes of each item?

Posted by snz3 on Stack Overflow See other posts from Stack Overflow or by snz3
Published on 2010-05-17T11:57:54Z Indexed on 2010/05/17 12:00 UTC
Read the original article Hit count: 284

Filed under:
|
|

(I'm new to python and django so please bear with me for a second. I apologise if this has been answered elsewhere and couldn't find it)

Let's say I have a Link model and through the django-voting application users can vote on link instances. How can I order those link instances according to their score, eg. display those with the higher score first.

I assume I could use the get_top manager of django-voting, but that would only give me the top scoring link instances and wouldn't take into consideration other parameters I would like to add (for example, those links that belong to a specific user or paging or whatever).

My guess would be to write a custom manager for my Link model where by I can filter a queryset according to each item's score. If I understand correctly that will require me to loop through each item, check its score, and then place it a list (or dictionary) which will then be sorted according to the score of each item. That wouldn't return a queryset but a dictionary with each item.

Am I missing something here?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-voting