Opened 15 years ago
Closed 11 years ago
#15571 closed New feature (wontfix)
AdminSite index and app_index methods could include the model_admin in the model_dict
| Reported by: | Batiste Bieler | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.2 |
| Severity: | Normal | Keywords: | admin, AdminSite, model_admin |
| Cc: | sverrejoh | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When sub-classing the "index.html" template for the admin interface, I wanted to show or hide some models (without disabling them, ie: still reachable in the admin as usual).
The model_dict doesn't contain the model_admin, so I needed to subclass the index method just to add this line:
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())),
'perms': perms,
'model_admin': model_admin, # added just this line
}
Then I can add some attribute "index_hide" to my ModelAdmin, and use it in my subclassed index.html to decide what to show.
Would it be a good idea to add this line to the admin, even if there is no use in the original template?
I believe it reflect some kind of common use-case. The need to access the model_admin within the index template seems natural to me.
Change History (7)
comment:1 by , 15 years ago
| Cc: | added |
|---|
comment:2 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 15 years ago
| Type: | → New feature |
|---|
comment:4 by , 15 years ago
| Severity: | → Normal |
|---|
comment:5 by , 14 years ago
| UI/UX: | unset |
|---|
comment:7 by , 11 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
This effect is usually achieved by permissions. Staff users only see models they're allowed to edit.
Super users may have a crowded index but they should be sufficiently computer-literate to use Ctrl-F.
Considering the lack of interest during the last three years, I don't think the problem is that common in practice, and I'll close the ticket.
Feel free to start a discussion on the django-developers mailing-list if I missed something.
Change UI/UX from NULL to False.