admin_order_field for Admin list_display not working for callable
|Reported by:||Kegan Gan||Owned by:||Brian Rosner|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the Admin, when using list_display, we should be able to make a sort callable if it is associated with certain database field through the use of attribute admin_order_field. Example:
def submitted_date(self, obj): return obj.created_at.strftime('%d %b %Y') submitted_date.short_description = 'Submitted Date' submitted_date.admin_order_field = 'created_at'
NOTE: created_at is a DB field in the model.
This is currently not working.
Searching through the code, I believe the bug is located in the following Django code. The attr variable seems will always be None.