Feat: admin date_hierarchy as a list

30 views
Skip to first unread message

Ádám Baróthi

unread,
Mar 31, 2023, 10:15:06 AM3/31/23
to Django developers (Contributions to Django itself)
Hello everyone,

I was wondering if it would be possible to extend the admin date_hierarchy logic to also accept a list of field names instead of just a single field name.

This would be useful for models that have multiple date fields that could be equally important to filter by (such as invoices, which typically have 4 associated dates).

By modifying the change_list admin template and the date_hierarchy admin template tag a little (see attachments) I was able to make it accept and use a list of strings. I unfortunately couldn't figure out how to make it also work with a single string, which would be important for not breaking existing configurations. It is aslo worth mentioning that I had to use --skip-checks for testing purposes, so the admin checks would also need to be adjusted accordingly.

Any thoughts on this?

Regards,
Adam
change_list.html
custom_admin_list.py
Reply all
Reply to author
Forward
0 new messages