Code

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#14140 closed (duplicate)

There is no way to override admin templates to the project level

Reported by: jacmkno Owned by: nobody
Component: Template system Version: master
Severity: Keywords: extends admin templates
Cc: rico.bl@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The template system allows to override admin templates for applications and models but for the project level it throws 'maximum recursion depth exceeded' because the template system keeps looking for the extended template in the current template path. For example this code generates the problem when placed in "project/templates/admin/base.html":

{% extends "/admin/base.html" %}
....

I have been unable to think of a solution for this problem yet, but I think this is an important missing feature. I think patches from Ticket #2414 may be used to solve this problem.

Attachments (0)

Change History (6)

comment:1 Changed 4 years ago by jacmkno

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 4 years ago by ramiro

  • Triage Stage changed from Design decision needed to Unreviewed

'untriaging' until another pair of eyes can look at this.

comment:3 Changed 3 years ago by rico

I think every admin template should extend a "base" template.
This way it would be possible to override templates on the project level (and maybe through external apps also).

As an example, my solution for customizing the admin index:

  • Move the original admin/index.html template to django/contrib/admin/templates/admin/base
  • Create the admin/index.html template that extends admin/base/index.html
    {# admin/index.html #}
    {% extends "admin/base/index.html" %}
    
    {# ... customizations here ... #}
    
  • On the project level, admin/index.html would extend admin/base/index.html and override the one bundled with the admin app

I can take this ticket if this solution is reasonable.

comment:4 Changed 3 years ago by rico

  • Cc rico.bl@… added

comment:5 Changed 3 years ago by lukeplant

  • Resolution set to duplicate
  • Status changed from new to closed

I think this is basically the same underlying issue as #8158. Please re-open if that's not the case. Note also the workaround on that ticket.

comment:6 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.