[Django]-How to order a Django QuerySet string property numerically?

4👍

You’ll probably need to fallback to Django’s extra function. Perhaps:

ordered = (qs.extra(select={"order_column": "CONVERT(column, INTEGER)"})
           .order_by("order_column"))

(Assuming you’re using MySQL)

Leave a comment