Opened 14 years ago

Closed 6 years ago

#12566 closed New feature (fixed)

admin action templates cannot be overriden on a per-app basis

Reported by: Ben Jackson Owned by: Tay Ray Chuan
Component: contrib.admin Version: 1.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

For example, if you want to customize the 'actions' dropdown menu you might think you could copy in actions.html and modify it. However, it is rendered in change_list.html by calling the admin_actions templatetag. Those templatetags use register.inclusion_tag which does not search for application- or model-specific versions of a template.

You can't even work around it by overriding callers like change_list.html without also overriding the templatetag (copying it and changing the template name).

Attachments (5)

0001-contrib.admin-refactor-updating-of-action_index-to-n.patch (3.8 KB ) - added by Tay Ray Chuan 14 years ago.
contrib.admin: refactor updating of action_index to not use inclusion tag
0000-admin-change_list.html-strip-trailing-whitespace.patch (1.2 KB ) - added by Tay Ray Chuan 14 years ago.
admin/change_list.html: strip trailing whitespace
0003-ref-contrib-admin-index-document-action_template.patch (1.8 KB ) - added by Tay Ray Chuan 14 years ago.
ref/contrib/admin/index: document action_template
0002-contrib.admin-allow-overriding-of-action-template-at.patch (3.8 KB ) - added by Tay Ray Chuan 14 years ago.
contrib.admin: allow overriding of action template at app-level
0001-contrib.admin-allow-overriding-of-actions.html-templ.patch (11.0 KB ) - added by Tay Ray Chuan 14 years ago.

Download all attachments as: .zip

Change History (19)

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

Triage Stage: UnreviewedAccepted

by Tay Ray Chuan, 14 years ago

contrib.admin: refactor updating of action_index to not use inclusion tag

comment:2 by Tay Ray Chuan, 14 years ago

Has patch: set
Owner: changed from nobody to Tay Ray Chuan
Status: newassigned

I have separated my fix into two parts:

  1. http://code.djangoproject.com/attachment/ticket/12566/0001-contrib.admin-refactor-updating-of-action_index-to-n.patch Part 1: The only reason for the template tag {%admin_action%} was to update the variable action_index in the context. The patch replaces it with a tag {% get_action_index %} to just spit out a value to be used as the action index, without template inclusion. The action template admin/actions.html is now included manually via {% include %} in admin/change_list.html.
  1. http://code.djangoproject.com/attachment/ticket/12566/0002-contrib.admin-allow-overriding-of-action-template-at.patch Part 2: Add some code to change_view select which template to use for the action form. I followed the style of template selection (eg. self.<thing>_template, followed by admin/mod/obj/<thing>.html, followed by...) from what we are already doing, eg. for change list, change form.

in reply to:  2 comment:3 by Tay Ray Chuan, 14 years ago

Replying to rctay:

  1. http://code.djangoproject.com/attachment/ticket/12566/0001-contrib.admin-refactor-updating-of-action_index-to-n.patch Part 1: The only reason for the template tag {%admin_action%}

I meant "The only reason for...to be around".

comment:4 by Tay Ray Chuan, 14 years ago

Summary: Admin templates rendered from templatetags cannot be overridden by applicationsadmin action templates cannot be overriden on a per-app basis

by Tay Ray Chuan, 14 years ago

admin/change_list.html: strip trailing whitespace

by Tay Ray Chuan, 14 years ago

ref/contrib/admin/index: document action_template

by Tay Ray Chuan, 14 years ago

contrib.admin: allow overriding of action template at app-level

comment:5 by Tay Ray Chuan, 14 years ago

Replaced patch so that app-level overriding of templates work.

comment:6 by Tay Ray Chuan, 14 years ago

Triage Stage: AcceptedReady for checkin

Please pardon me if the status is inappropriate; it's my first time advancing a ticket's triage stage.

comment:7 by Ramiro Morales, 14 years ago

Needs tests: set
Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Ideally, ticket stage field changes to accepted or ready for checkin shouldn't be performed by patch submitter and/or ticket reporter. Review by another pair of eyes is preferred, see http://docs.djangoproject.com/en/1.1/internals/contributing/#triage-by-the-general-community

Also, please merge all the patches in one file.

comment:8 by Tay Ray Chuan, 14 years ago

Needs tests: unset
Patch needs improvement: unset

comment:9 by Tay Ray Chuan, 14 years ago

Removed stray print.

comment:10 by Matt McClanahan, 13 years ago

Severity: Normal
Type: New feature

comment:11 by patchhammer, 13 years ago

Easy pickings: unset
Patch needs improvement: set

0001-contrib.admin-allow-overriding-of-actions.html-templ.patch fails to apply cleanly on to trunk

comment:12 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:13 by Carlton Gibson, 6 years ago

This was resolved by #27728, which allowed overriding admin templatetag's templates.

comment:14 by Carlton Gibson, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top