How to group models in django admin?
Lets say I have a group of models that must be kept separate (visually) in the admin from another group.
Right now they are alphabetic, which jumbles them.
I'd like to organize them this way:
Group 1: (custom named)
- Model 1
- Model 4
Group 2 (custom named)
- Model 2
- Model 3
I cannot seem to find the documentation on how to do this. Is this even possible?
Solution 1:
I do not think that splitting up your business logic, i.e. your app, when all you want to achieve is some kind of markup is the right way. Instead I found the Python package django-modeladmin-reorder that lets you achieve this easily. You can combine its feature of labelling apps and reordering models to group models of one app in the admin. After following the installation instructions, add something like this to your settings.py
ADMIN_REORDER = (
# First group
{'app': 'myapp', 'label': 'Group1',
'models': ('myapp.Model_1',
'myapp.Model_4',)
},
# Second group: same app, but different label
{'app': 'myapp', 'label': 'Group2',
'models': ('myapp.Model_2',
'myapp.Model_3',)
},)