Custom django menu and page

320 views
Skip to first unread message

Juan Antonio García Cano

unread,
Oct 11, 2013, 5:57:49 AM10/11/13
to django...@googlegroups.com
In my django admin site, i have the menu with the name of my app and in this section all the models that i have registered in admin.py

I want to know if it is posible to put in the main menu and submenu a custom entry, with custom templates. (These pages will be only for work and show data, there will be not "admin.site.register(...)")

It is posible to do this?

Yevgeniy Shchemelev

unread,
Oct 11, 2013, 6:48:43 AM10/11/13
to django...@googlegroups.com
Yes. It's can be done on template layer.
Just create custom index admin template. See example in django source.
You need to create you own module table with appropriate model rows.

For example:

{% for app in app_list %}
    {% if app.app_label == 'insert_after_app_label %}
        <div class="app-custom module">
        <table>
        <caption>
            <a href="javascript:void(0);" title="No list presentation in this entry">My custom entry</a>
        </caption>

        {% for model in app.models %}
            <tr class="model-custom-entry">
                <th scope="row"><a href="/my_view_url/">My view title</a></th>
                <th scope="row">My view title</th>
                <td><a href="/my_view_add_link/" class="addlink">{% trans 'Add' %}</a></td>
                <td><a href="/my_view_change_link/" class="changelink">{% trans 'Change' %}</a></td>
            </tr>
        </table>
        </div>
    {% endif %}
    ...
{% endfor %}
Reply all
Reply to author
Forward
0 new messages