Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#28486 closed Bug (invalid)

Template FileLoader can't find widget templates

Reported by: Andrey Owned by: nobody
Component: Template system Version: 1.11
Severity: Normal Keywords: widgets, templates, admin
Cc: rusanov.andrey.mail@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have both apps and file loaders in my project. I load custom directory called "templates" in the root of the project.

In case I want to override template for field widget from Django Admin (perhaps it related to regular widgets as well) and I create a file under "templates/admin/widgets/clearable_file_input.html". Nothing happens. If I will move it somewhere under "<my app>/templates/widgets/clearable_file_input.html" it works fine. However, I can override "admin/base.html" and few other templates from admin by placing them in "templates/" folder.

I played around and found that when looking for templates for widget Django loads all template directories for apps, but doesn't load anything from DIRS parameter. In the same time, it loads everything properly for other templates.

If description is messy or unclear please ask, and I will clarify unclear parts.

Change History (4)

comment:1 by Tim Graham, 7 years ago

Resolution: invalid
Status: newclosed

Do you have FORM_RENDERER = 'django.forms.renderers.TemplatesSetting' in your settings? The default DjangoTemplates renderer doesn't consult the TEMPLATES setting. Please read The form rendering API documentation.

comment:2 by Federico Capoano, 6 years ago

Hi,

I just stumbled upon this issue and found the solution thanks to this ticket, therefore thank you very much for pointing out the solution.

However, I wonder why the behaviour that I expected (which I believe also Andrey expected and anyone with a good experience with django would expect) cannot be set as the default one.
Is it a backward compatibility issue, or what?

Best regards
Federico Capoano

comment:3 by Paolo, 6 years ago

+1 for Federico Capoano and agree with his statement and the fact that the pre-configured behaviour is NOT the one expected, I have lost quite a bit of time on this and why I could not override the template using the standard Django strategy.
I think that would have made much more sense to explain that the "django.forms" app should be added in the installed apps to allow the templates to be found!

comment:4 by Tim Graham, 6 years ago

Yes, there was extensive discussion about this feature and the decision about which renderer to use as the default.

Note: See TracTickets for help on using tickets.
Back to Top