Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reorder model objects in django admin panel

I have several configuration objects in django 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?

like image 918
axe Avatar asked Feb 05 '14 13:02

axe


2 Answers

So I've just wrote a django package that will allow you reorder django app list/ rename app label and model names (including 3rd party apps) — you can download it from here:

https://github.com/mishbahr/django-modeladmin-reorder

like image 131
mishbah Avatar answered Sep 28 '22 04:09

mishbah


If you don't mind using a dirty trick, prepend verbose_name_plural of your models with a certain number of invisible zero-width spaces. E.g. prepend "Email config" with 1 zero-width space, "General config" with 2 and "Network config" with 3. This is really the simplest method and I've yet to find any shortcomings.

like image 34
Dae Avatar answered Sep 28 '22 04:09

Dae