1

I overrides admin templates and I have something like this:

{% for app in app_list %}
    <li>
        <a href="#">
            <img src="{{ MEDIA_URL }}images/list.png"/>
            <span>{{ app.name }}</span>
        </a>
        <ul class="drawer" style="display: none;">
            {% for model in app.models %}
                <li>
                    <a href="{{ model.admin_url }}">
                        <span>{{ model.name }}</span>
                    </a>
                </li>
            {% endfor %}
        </ul>
    </li>
{% endfor %}

But it shows me menu only on index page. How to get app_list on each admin page?

e-nouri
  • 2,576
  • 1
  • 21
  • 36
Nips
  • 13,162
  • 23
  • 65
  • 103
  • What do you mean in each admin page ? can you give more details on what you want and what you have ? – e-nouri Oct 22 '14 at 08:09
  • for example in edit/add new object page or in change_list page, I want to show menu generated from app_list - always – Nips Oct 22 '14 at 08:13
  • I think your only solution is to modify `base_site.html` since every page extends from it `{% extends "admin/base_site.html" %}` and include what you want ! – e-nouri Oct 22 '14 at 08:16

2 Answers2

0

I think your only solution is to modify base_site.html since every page extends from it {% extends "admin/base_site.html" %} and include what you want ! You have to create an admin folder and place your modified base_site.html inside. You have to make sure that django loads the template dir correctly, see this question (django-override-admin-template) for more clarifications.

Community
  • 1
  • 1
e-nouri
  • 2,576
  • 1
  • 21
  • 36
0

I think you can move your code into {% block nav-global %}{% endblock %} Example, in your template file, something like this:

{% block nav-global %}
    {% for app in app_list %}
        <li>
            <a href="#">
                <img src="{{ MEDIA_URL }}images/list.png"/>
                <span>{{ app.name }}</span>
            </a>
            <ul class="drawer" style="display: none;">
                {% for model in app.models %}
                    <li>
                        <a href="{{ model.admin_url }}">
                           <span>{{ model.name }}</span>
                        </a>
                   </li>
                {% endfor %}
           </ul>
       </li>
    {% endfor %}
{% endblock %}
{% block content %}
......
{% endblock %}
Davis
  • 51
  • 3