Re: [Django] #32109: Cannot add content to admin sidebar without breaking layout

2 views
Skip to first unread message

Django

unread,
Oct 15, 2020, 3:25:12 AM10/15/20
to django-...@googlegroups.com
#32109: Cannot add content to admin sidebar without breaking layout
-------------------------------------+-------------------------------------
Reporter: Ben Davis | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:
Keywords: admin sidebar | Triage Stage:
template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

Hi Ben.

This is a curious one.

Have a look at this diff:

{{{
$ git diff
diff --git a/django/contrib/admin/templates/admin/index.html
b/django/contrib/admin/templates/admin/index.html
index b6e84b64ed..f075aef37f 100644
--- a/django/contrib/admin/templates/admin/index.html
+++ b/django/contrib/admin/templates/admin/index.html
@@ -18,8 +18,22 @@
{% endblock %}

{% block sidebar %}
+
+<div style="float:right;position:relative;margin-right:
-300px;width:260px;">
+<h2>On top</h2>
+<p>the float and clear lets us position OK.</p>
+<p>No styling.</p>
+</div>
+<div style="clear: right;"></div>
+
<div id="content-related">
+ <h2>Inside #content-related</h2>
+ <p>In the grey sidebar.</p>
+ <p>But style mismatch</p>
+
<div class="module" id="recent-actions-module">
+ <h2>Inside #recent-actions-module</h2>
+ <p>Picks up styling from Recent Actions.</p>
<h2>{% translate 'Recent actions' %}</h2>
<h3>{% translate 'My actions' %}</h3>
{% load log %}
@@ -47,4 +61,7 @@
{% endif %}
</div>
</div>
+<h2>After all existing content</h2>
+<p>Ends up under the app list.</p>
+
{% endblock %}
}}}

There's three ''obvious'' positions for extra content in the sidebar:

1. Right at the top, outside `#content-related` (Bottom is in the diff
but...)
2. Inside `#content-related` (top or bottom)
3. Inside `#recent-actions-module` (again top or bottom)

If it's 1. I'm inclined to think ''Just use CSS and a clearing div to put
it in the right place''.

Number 2. is your suggestion from the PR, but if you put it in 3, you get
the styling from the Recent Actions module for free.

So I'm a bit 🤔 — what do you think?

(Half inclined to say that we should pull the inner HTML of #recent-
actions-module into an included template to allow folks to go for whatever
option they want here quite easily.)

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

Django

unread,
Oct 20, 2020, 2:51:24 AM10/20/20
to django-...@googlegroups.com
#32109: Cannot add content to admin sidebar without breaking layout
-------------------------------------+-------------------------------------
Reporter: Ben Davis | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution: wontfix

Keywords: admin sidebar | Triage Stage:
template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

I'm going to close as wontfix for the moment. Go with Option 1 ''Just use
CSS and a clearing div to put it in the right place.''
Happy to discuss more if you (or anyone wants to follow up)
Thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/32109#comment:4>

Reply all
Reply to author
Forward
0 new messages