axe axe - 1 year ago 146
Python Question

Reorder model objects in django admin panel

I have several configuration objects in

admin panel.
They are listed in the following order

  • Email config

  • General config

  • Network config

Each object can be configured separately, but all of them are included in
General config
. So basically you will need mostly
General config
, so I want to move it to the top.
I know how to order fields in a model itself, but how to reorder models?

Answer Source

I don't see an obvious solution to this — the models are sorted by their _meta.verbose_name_plural, and this happens inside the AdminSite.index view, with no obvious place to hook custom code, short of subclassing the AdminSite class and providing your own index method, which is however a huge monolithic method, very inheritance-unfriendly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download