#32324: Wrapping the header in base.html of contrib.abmin in {% blocks %}.
-------------------------------------+-------------------------------------
Reporter: Muskan Vaswan | Owner: Muskan
Type: | Vaswan
Cleanup/optimization | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:
Keywords: admin customize | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Old 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.
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 due
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):
Replying to [comment:7 Carlton Gibson]:
> Hmmm. I'm a bit sceptical that very many people want to remove the
header entirely, but I agree that a single block would make that feasible.
>
> > 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
>
> Query: an amount of CSS resolves that no?
Yes, adding CSS to make would surely make it disappear, but I'm not sure
if that would be the best way to do it, but again, that's just what I
think.
About the first point, I have come across many occasions when I needed to
replace the admin top-nav and personally, I don't think its that uncommon
to have a themed top-bar that you want to use throughout the website.
At the same time, I agree, it's not a pressing issue by any means.
I guess it's just a matter of deciding whether making something like this
more convenient for the user justifies adding another block...
--
Ticket URL: <https://code.djangoproject.com/ticket/32324#comment:8>
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.db90ea3caed902a7f2bc188edf601e20%40djangoproject.com.