qwerty000
qwerty000

Reputation: 186

Django extend admin home page - Add elements to the content area

I'm trying to add a link inside the content area of the admin home page. I'm using this template:

{% extends 'admin/base.html' %}

{% block title %}
    Custom title
{% endblock %}

{% block content %}
    <a href="some/url">LINK</a>
{% endblock %}

The title is working so I know the extended template is working but the block content is not working, I can't see the link in my admin home page. Acoording to django's github repository (https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/base.html) the block name is correct so I don't know where my error is.

How can I add elements to the content area of my admin home page?

Upvotes: 1

Views: 809

Answers (1)

Nitin Nain
Nitin Nain

Reputation: 5483

That's because the {% block content %} is getting overridden by other templates in the django admin.

For e.g. contrib/admin/templates/admin/change_form.html will override the content block, as will all other admin pages.

Since you only want to change the Django Admin homepage, you can override this template instead admin/templates/admin/index.html

Upvotes: 0

Related Questions