Opened 3 years ago
Closed 3 years ago
#32826 closed New feature (duplicate)
Allow for custom groupings in Django Admin
Reported by: | Karim Ouada | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 3.2 |
Severity: | Normal | Keywords: | admin |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
I recently stumbled upon a small issue in my Django project and thought it might be something that could be helpful for other people as well.
I had a Django app and registered my entities in the Django admin. I didn't like the fact that they were all grouped together, so I wanted to separate them into different subcategories. Obviously Django groups those entities by app_name
, which I didn't want to change in the models since many things rely on it. So instead I decided to extend the _build_app_dict
method in AdminSite to allow for a custom name, as it seems that the app_dict
created in that method is only a representation for the UI in the Django admin.
The way it would work is that there is a new optional parameter in the admin.ModelAdmin
called group_name
and you can specify a group/category that the entities in the Django admin will be grouped in. If you don't specify it then the default is just the app_label
.
I would definitely love to contribute back to Django with this small improvement and I know there are quite some threads online where people were looking for such behavior. Let me know if you think that makes sense and could be helpful.
I already created a small PR with a sample implementation:
https://github.com/ouadakarim/django/pull/1
Change History (1)
comment:1 by , 3 years ago
Has patch: | unset |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Duplicate of #7497 (see also comment).