Opened 3 years ago

Closed 3 years ago

#33345 closed Bug (invalid)

Forms does not search external template directories

Reported by: Guillaume Quenneville Owned by: nobody
Component: Forms Version: 4.0
Severity: Normal Keywords: template discovery forms
Cc: Guillaume Quenneville, David Smith Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It seems like the new form templates ignores external template directories? (or I did something silly). It works for app's local template directory.

I created a test repo
https://github.com/GuillaumeQuenneville/djangoform.git

Django finds home.html (parent template) but does not find the item_form.html template in the same dir.

Adding the form template to the test app's local templates folder fixes the discovery issue (rename item_form.html.bk -> item_form.html in repo)

As a test, I turned on the debugger before the render in the view. Calling render(request, 'home.html') returns a 200 and no error, calling form.render(template_name='home.html') says home.html not found, idem for form.render() saying item_form.html not found. So there is a difference in template discovery??

Change History (2)

comment:1 by Guillaume Quenneville, 3 years ago

Cc: Guillaume Quenneville added
Component: Template systemForms

comment:2 by Mariusz Felisiak, 3 years ago

Cc: David Smith added
Resolution: invalid
Status: newclosed

Form.render() uses Form.default_renderer when the renderer argument is not specified, and Form.default_renderer defaults to the FORM_RENDERER setting which defaults to `'django.forms.renderers.DjangoTemplates'`. If you want to render templates with customizations from your TEMPLATES setting, you should change the renderer to use the `TemplatesSetting` renderer at any of these levels.

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