Django - extend admin template

Asked

Viewed 183 times

2

could anyone indicate the best way to extend the Django template? and what is the best way to share a template with the Adminstrative area and the site.

I am using Django version 1.8.6 and Django-bootstrap3

thank you.

  • 2

    "Better" in what sense? As for the administrative area, when doing collecttemplate all templates used by admin will end up in a folder, so you can see what your structure is and then customize it (I have no experience with this, but I think the ideal is to copy the default template to one of your apps - preserving the path - and change it there).

  • I get it @mgibsonbr. I meant "better" in the sense of implementation, I saw some examples where they copied the master template on the machine’s Jango, others take the github template. thanks for the tips

1 answer

1


Following the answer of that post, you can use the djangosnippets and extend the admin template in an easy way. See the example:

{% extends "admin:admin/index.html" %}

{% block sidebar %}
    {{block.super}}
    <div>
        <h1>Extra links</h1>
        <a href="/admin/extra/">My extra link</a>
    </div>
{% endblock %}

I don’t know if this is the best way, but it is one of the ways. I saw that the post is old, but I think the answer is still valid. Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.