Add Flag to turn on/off the default alphabet sort order in Admin Django nav bar

for now the Django module will default sort the module in alphabet order, and show in the admin portal navigation bar.
Eg: Module A, Module B, Module C. will by sort to A, B, C.
there are some ways to change the order, eg trick the verbose_name of module, to manipulate the order, but it is not straight forward, and difficult to maintain.

I check the code, it is happen in get_app_list function, which by default sort by model name.
so thinking can we have a bool flag in setting file eg: MENU_ALPHABET_ORDER.


if it is True, will be same behaviour as before.
if it is False, the order will be based on the order when it registered to the admin. (the dict is default ordered since python3.6), so can just change the register sequence, will help to sort the menu accordingly.

Just an idea, not sure whether a good solution

You can override this method in your AdminSite class to implement this any way you’d like. That method exists as a published API so you would be able to rely upon it, subject to the normal Django deprecation policy.

You might also be interested in an earlier discussion on this topic - see Reordering list of models in Django Admin

1 Like