#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: master
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


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 Changed 22 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 22 months ago by resry

  • Owner changed from nobody to resry
  • Status changed from new to assigned

comment:3 Changed 22 months ago by resry

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

comment:4 Changed 22 months ago by Keryn Knight <django@…>

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

comment:5 Changed 22 months ago by claudep

  • Has patch set
  • Needs tests set

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

comment:6 Changed 20 months ago by pouete

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

Fix+test cases

comment:7 Changed 19 months ago by timo

  • 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 Changed 19 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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