Search code examples
pythondjangowebweb-applications

How to order a filtered django query set by a decimal field


I am trying to sort my query set by a "ranking value" which I have as a decimal field in my django model, however it seems the "order_by" function doesn't seem to work? my query set is always the same, with no ordering.

I have tried the google but come up short, am I missing something here?


Solution

  • I need to see your code, but without looking i can ask you to use the "round(x)" function (where x is a float) on all your values, it will not change the ranking (mathematically sure about this), and order_by will work

    Would love to see your code indeed !

    Tip : Use a for loop to round all the numbers or make a function