Please consider the following example:
# models.py
class Case(models.Model):
number = models.SmallIntegerField(null=False, blank=False)
year = models.SmallIntegerField(null=False, blank=False)
...
#admin.py
@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}'
Now how can I specify the order to be by '-year'
and '-number'
using the admin.display()
decorator?
If it can not be done with the admin.display()
decorator, is there another way to achieve that?
Thanks
Thank you @Willem Van Onsem for the patch you provided in order to make this possible.
Even thought the developers didn't agree to implement it. Thank you for the time you spent patching it and opening the #34646 ticket.