#32324: Wrapping the header in base.html of contrib.abmin in {% blocks %}.
-------------------------------------+-------------------------------------
     Reporter:  Muskan Vaswan        |                    Owner:  Muskan
         Type:                       |  Vaswan
  Cleanup/optimization               |                   Status:  closed
    Component:  contrib.admin        |                  Version:  3.1
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:  admin customize      |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  1
-------------------------------------+-------------------------------------

Old description:

> The Django admin template can be overridden and extended by the user.
> However, flexibility to customize the admin page can be increased by
> putting larger chunks of code inside a `{% block  ... %}... {% endblock
> %}`. This will be useful as it will allow the user to completely rewrite
> an entire segment of the page without having to override smaller elements
> or the entire template.
>
> For example, the user can overwrite the entire navbar if the header was
> put inside `{% block header %}` simply by extending the template.
>
> Refer to this conversation [https://groups.google.com/g/django-
> developers/c/Q8I-0-2Sn4M] (point 2) for the full discussion

New description:

 === Use case
 Allowing the user to overwrite the Top Navigation Bar od the admin page.

 === Existing method

 to Overwrite the top nav-bar without having to overwrite the entire
 template of base.html, the user currently has to add the

 {{{
 {% extends "admin/base_site.html" %}
 {% load static %}
 {% block branding %}
 {% endblock %}
 }}}

 to admin/base_site.html and`

 {{{
 {% extends "admin/base.html" %}
 {% load static %}
 {% block usertools %}
 {% endblock %}
 }}}
  to admin/base.html.
 No other method, other than overwriting the entire template exists.

 === Issue with Existing method

 1. Even after doing the above the top-bar doesn't entirely disappear dude
 to the CSS applied on the <div> with the id of header
 (Image attached)

 2. The user must extend two separate files to even make this happen.

 === Solution

 The simple solution is to wrap the entire header class using {% block ...
 %}. So the final django/admin/base.html would have:

 {{{
     <!-- Header -->
     {% block header %}
     <div id="header">
         ...
     </div>
     {% endblock %}
     <!-- END Header -->

 }}}

 === Final Result
 The user will be able to overwrite the default blue-green nav-bar
 *entirely* by adding


 {{{
 {% extends "admin/base.html" %}
 {% load static %}
 {% block header %}
 {% endblock %}
 }}}
 to admin/base.html.

--

Comment (by Muskan Vaswan):

 In consideration of that, I wrote a more specific and comprehensive Issue.
 I hope this makes it more clear.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32324#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.4ed5c1fe7dc79ea4790873f51d22f1fe%40djangoproject.com.

Reply via email to