Opened 15 years ago
Closed 7 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)
Change History (19)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
by , 15 years ago
Attachment: | 0001-contrib.admin-refactor-updating-of-action_index-to-n.patch added |
---|
follow-up: 3 comment:2 by , 15 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
I have separated my fix into two parts:
- 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 variableaction_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 templateadmin/actions.html
is now included manually via{% include %}
inadmin/change_list.html
.
- 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 byadmin/mod/obj/<thing>.html
, followed by...) from what we are already doing, eg. for change list, change form.
comment:3 by , 15 years ago
Replying to rctay:
- 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 , 15 years ago
Summary: | Admin templates rendered from templatetags cannot be overridden by applications → admin action templates cannot be overriden on a per-app basis |
---|
by , 15 years ago
Attachment: | 0000-admin-change_list.html-strip-trailing-whitespace.patch added |
---|
admin/change_list.html: strip trailing whitespace
by , 15 years ago
Attachment: | 0003-ref-contrib-admin-index-document-action_template.patch added |
---|
ref/contrib/admin/index: document action_template
by , 15 years ago
Attachment: | 0002-contrib.admin-allow-overriding-of-action-template-at.patch added |
---|
contrib.admin: allow overriding of action template at app-level
comment:6 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Please pardon me if the status is inappropriate; it's my first time advancing a ticket's triage stage.
comment:7 by , 15 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
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 , 14 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
by , 14 years ago
Attachment: | 0001-contrib.admin-allow-overriding-of-actions.html-templ.patch added |
---|
comment:10 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 14 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:13 by , 7 years ago
This was resolved by #27728, which allowed overriding admin templatetag's templates.
comment:14 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
contrib.admin: refactor updating of action_index to not use inclusion tag