#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.

-- 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.6a6be560ad627e8b0f68b14ca05d6079%40djangoproject.com.

Reply via email to