Django Order_BY custom function
问题 I have field in model roll_numb . The roll_numb has values as follows. 070-001 070-007 070-343 080-002 080-008 When i order_by roll_numb the sorting is as it is above. I want to split the roll_numb by - and sort by the remainder. (i.e. 001, 002, 008) Code class Meta: ordering = ['roll_numb'] 回答1: I think it is not possible to order a queryset by method of model in Django's ORM scope. So in order to sort your queryset by your custom method, I recommend 2 ways: First qs = mymodel.objects.all()