Categories
Python Answers

How to override and extend basic Python Django admin templates?

Spread the love

To override and extend basic Python Django admin templates, we can use the extends helper.

For instance, we write

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

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

to use extends with the admin template file we want to extend from.

And then we add our own items below the extends block.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *