# Failing to overwrite admin templates

**URL:** <https://forum.djangoproject.com/t/failing-to-overwrite-admin-templates/31635>\
**Category:** The Admin\
**Created:** [May 30, 2024, 11:51am UTC](https://forum.djangoproject.com/t/failing-to-overwrite-admin-templates/31635 "2024-05-30T11:51:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elias](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/elias/32/11042_2.png) [@elias](https://forum.djangoproject.com/u/elias)\
**Post date:** [May 30, 2024, 11:51am UTC](https://forum.djangoproject.com/t/failing-to-overwrite-admin-templates/31635/1 "2024-05-30T11:51:34Z")

</div>

Hi,

I want to modify the template “`delete_confirmation.html`” in the admin view. The general approach is described in the [documentation](https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#admin-overriding-templates). However, I did not succeed to follow the steps.

I tried to create an example project (`testadmintemplates`) with an app (`testapp`) and add the following template:

```auto
{% extends "admin/delete_confirmation.html" %}

{% block delete_confirm %}
  <p>{% blocktranslate with escaped_object=object %}Are you sure you want to delete the {{ object_name }} "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktranslate %}</p>
  {% include "admin/includes/object_delete_summary.html" %}
  <h1>asdfasdfasdfasdf</h1>
  <h2>{% translate "Objects" %}</h2>
  <form method="post">{% csrf_token %}
  <div>
  <input type="hidden" name="post" value="yes">
  {% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1">{% endif %}
  {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}">{% endif %}
  <input type="submit" value="{% translate 'Yes, I’m sure' %}">
  <a href="#" class="button cancel-link">{% translate "No, take me back" %}</a>
  </div>
  </form>
  <ul id="deleted-objects">{{ deleted_objects|unordered_list }}</ul>
{% endblock %}

```

I tried a number of different places for the template but none of them worked:

- ./testadmintemplates/templates/admin/delete\_confirmation.html
- ./testapp/templates/admin/delete\_confirmation.html
- ./templates/admin/delete\_confirmation.html
- ./templates/admin/testapp/delete\_confirmation.html
- ./templates/admin/testapp/testmodel/delete\_confirmation.html
- ./templates/testapp/admin/delete\_confirmation.html
- ./templates/testadmintemplates/admin/delete\_confirmation.html

Here are the changes I did to the code apart from adding the templates

```auto
--- a/testadmintemplates/settings.py
+++ b/testadmintemplates/settings.py
@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
 # Application definition
 
 INSTALLED_APPS = [
+ 'testapp',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -54,7 +55,7 @@ ROOT_URLCONF = 'testadmintemplates.urls'
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [],
+ 'DIRS': [BASE_DIR/'templates'],
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [

```

```auto
--- a/testapp/admin.py
+++ b/testapp/admin.py
@@ -1,3 +1,8 @@
 from django.contrib import admin
 
 # Register your models here.
+
+from django.contrib import admin
+from .models import TestModel
+
+admin.site.register(TestModel)

```

```auto
--- a/testapp/models.py
+++ b/testapp/models.py
@@ -1,3 +1,6 @@
 from django.db import models
 
 # Create your models here.
+
+class TestModel(models.Model):
+ x = models.CharField(max_length=199)

```

Can anyone help?
