templates: search custom template for simple widgets only (#56252)

This commit is contained in:
Serghei Mihai 2021-08-19 10:36:36 +02:00
parent 6bf6be86e0
commit e50ab0dfe1
1 changed files with 4 additions and 1 deletions

View File

@ -124,7 +124,10 @@ def with_template(form):
form_template = template.loader.get_template('gadjo/form.html')
fields_with_templates = []
for field in form:
templates = ['gadjo/%s-widget.html' % field.field.widget.input_type, 'gadjo/widget.html']
widget = field.field.widget
templates = ['gadjo/widget.html']
if hasattr(widget, 'input_type'):
templates.insert(0, 'gadjo/%s-widget.html' % widget.input_type)
fields_with_templates.append(
(
field,