Opened 10 years ago

Closed 10 years ago

#21371 closed Cleanup/optimization (fixed)

Admin templates use a `bodyclass` block without ever calling super.

Reported by: Keryn Knight <django@…> Owned by: resry
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

A reasonable expectation is, I think, to be able to subsume the admin/base_site.html template to do a few tweaks for display purposes, by throwing it in an earlier INSTALLED_APP or into one of the paths set in TEMPLATE_DIRS; for the most part, this works as expected.

However, trying to do something like:

{% extends "admin/base.html" %}
{% block bodyclass %}mymagicalbase {{ block.super }}{% endblock %}

does not work as desired, because subsequent templates [those which inherit from base_site] define the bodyclass block without calling super themselves; see GitHub search demonstrating the files affected; with the notable exception of app_index, which does call super.

By contrast, all of the templates which require extrastyles do call super to ensure the template hierarchy's block representation is preserved as the template author designed.

Change History (8)

comment:1 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedAccepted

comment:2 by resry, 10 years ago

Owner: changed from nobody to resry
Status: newassigned

comment:3 by resry, 10 years ago

I've submitted a pull request from my branch at ticket_21371.

comment:4 by Keryn Knight <django@…>, 10 years ago

For completeness' sake, it looks like there was previously an attempt to fix a small subset of the affected templates, in #7425

comment:5 by Claude Paroz, 10 years ago

Has patch: set
Needs tests: set

Thanks Keryn, #7425 has been set as a duplicate.

comment:6 by Julien GODIN, 10 years ago

Hello !
I have a pull request to address this ticket !

Fix+test cases

comment:7 by Tim Graham, 10 years ago

Needs tests: unset
Patch needs improvement: set

I've reviewed the pull request and left comments for improvement. Please uncheck "Patch needs improvement" when it's updated.

comment:8 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In f5123c7291e855713b59e739bad0e50a1d50d3ef:

Fixed #21371 -- Added the block.super to admin bodyclass blocks.

Thanks Keryn Knight for the report.

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