﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34646	Ordering a Django admin column based on multiple model fields	Willem Van Onsem	nobody	"This issue is based on [this StackOverflow question](https://stackoverflow.com/q/76425892/67579). Here a Django admin column is made:

{{{
class Case(models.Model):
    number = models.SmallIntegerField()
    year = models.SmallIntegerField()
}}}

with an admin column that combines the number and year:

{{{
@admin.register(Case)
class CaseAdmin(admin.ModelAdmin):
    list_display = ['case_number']
    ordering = ['-year', '-number']

    @admin.display(ordering=['-year', '-number'])
    def case_number(self, case):
        return f'{case.number} / {case.year}'
}}}

Currently it is not possible to use an `ordering` that is a tuple of ""orderables"". We can for example use `Concat('year', Value('/'), 'number')`, but that will not work for numbers, since `'10' < '2'` for strings.

The modification seems not to be that difficult, we can look if it is a list/tuple and then do the same logic, for each item in the list and add these to the fields."	New feature	closed	contrib.admin	4.2	Normal	duplicate			Unreviewed	0	0	0	0	1	0
