Edit Django admin exit template?

I want to make a very small change to the Django admin exit page.

I know how to use templates to override Django admin templates, so I tried to do the same with the exit file.

I installed a new template in templates/registration/logged_out.html . The contents of this file are as follows:

 {% extends "registration/logged_out.html" %} {% block content %} <p>Thanks for using the site.</p> <p><a href="../">Log in again</a></p> <p><a href="/">Return to the home page</a></p> {% endblock %} 

However, something is definitely wrong, because when I try to exit admin, the site stops working.

I found a Django docs page recommending using AdminSite to change the base template and exit pages, but is it really necessary for such a tiny change?

If so, does anyone have an example of how I can customize the exit template? I'm pretty intimidated by the instructions for AdminSite.

Thanks.

+4
source share
2 answers

The reason for the completion of manage.py runningerver is the inheritance loop.

Django loads "registration / logged_out.html" and tries to load its parent: "registration / logged_out.html". Unfortunately, the parent is the same template, and so we end the template inheritance cycle. Manage.py will fail with some error option ...

You can easily avoid the problem by expanding the parent copy of the original "registration / logged_out.html" → "admin / base_site.html". I.e:

 {% extends "admin/base_site.html" %} {% load i18n %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a></div>{% endblock %} {% block content %} <p>Thanks for using the site.</p> <p><a href="../">Log in again</a></p> <p><a href="/">Return to the home page</a></p> {% endblock %} 
+5
source

You get a cycle to import templates. The template loader will not load the basic template form wherever you install Django, as it sees that you have this template in the project template folder.

I think you need to copy the logout template where you installed Django to the project template folder. Unfortunately, this is the only way to work. This method also means that if changes are made to the Django admin templates, you will have to manually apply them to your modified templates.

+1
source

All Articles