0

Context

I want to override the following django templates:

  • django/contrib/admin/templates/admin/widgets/clearable_file_input.html
  • django/contrib/admin/templates/admin/auth/user/change_password.html

With these custom templates:

  • <project_root>/templates/admin/widgets/clearable_file_input.html
  • <project_root>/templates/admin/auth/user/change_password.html

My TEMPLATES settings are configured as followed:

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [os.path.join(BASE_DIR, "templates")],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]

Problem

While I have managed to successfully override a lot of other templates that exist in the django/contrib/admin/templates/admin/ path, I cannot seem to be able to override templates that exist in the paths mentioned above.

Regarding the widgets, I also tried the instructions found in the docs here and also adding FORM_RENDERER = 'django.forms.renderers.TemplatesSetting' to no avail.

Dimitris Karagiannis
  • 8,942
  • 8
  • 38
  • 63
  • Have you seen these : [https://stackoverflow.com/a/52901700/6143954](https://stackoverflow.com/a/52901700/6143954)? – NKSM Jan 27 '21 at 20:25
  • Yes, it did not help – Dimitris Karagiannis Jan 28 '21 at 09:53
  • See: [Templates which may be overridden per app or model](https://docs.djangoproject.com/en/dev/ref/contrib/admin/#templates-which-may-be-overridden-per-app-or-model). – NKSM Jan 28 '21 at 10:41
  • Yeah, this does not really help either. All it says is about templates that can only be overriden globally and not per model/app. I was not trying to override the templates I mentioned per model/app anyway, I wanted to override them globally – Dimitris Karagiannis Jan 28 '21 at 11:52

0 Answers0