Opened 14 years ago

Closed 10 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 sverrejoh, 14 years ago

Cc: sverrejoh added

comment:2 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Luke Plant, 14 years ago

Type: New feature

comment:4 by Luke Plant, 14 years ago

Severity: Normal

comment:5 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:6 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:7 by Aymeric Augustin, 10 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top