I'm not sure if having the default renders insert the built-in form 
templates directory after the app dirs (as opposed to before, as usual with 
'DIRS') is the best approach. On the PR, we discussed adding a new 
TEMPLATES 'POST_APP_DIRS' option to accomplish this but it might be 
unneeded complexity. I mentioned, "I'm concerned that it gives the idea 
that third-party apps should be overriding templates to customize things 
when that's really not appropriate since only the template in the earliest 
installed app will be found." Carl said "Yeah, I agree that third-party 
apps in most cases shouldn't be overriding form widgets (though I suppose I 
could see some exceptions for e.g. something like a django-bootstrap-forms 
app, if it clearly advertises that this is what it does)." If overriding 
templates via app directories is the exception, should that behavior be 
eased by default? I think using a custom renderer (perhaps even one 
provided by the app itself) that uses DIRS would be a more explicit setup.

On Wednesday, December 7, 2016 at 12:00:57 PM UTC-5, Carl Meyer wrote:
>
> Hi Tim, 
>
> On 12/07/2016 08:41 AM, Tim Graham wrote: 
> > This scheme seems to be working well so far. 
>
> Great, thanks for working on implementation. I did have intentions of 
> putting together the implementation once I'd gotten your feedback on the 
> design, but I won't complain if you've already done it :-) 
>
> > One thing you may not have thought of is that switching 
> > to JinjaTemplateRenderer is incompatible with the admin because jinja2 
> > templates aren't provided for those widgets. I think the reasoning was 
> > that they're complicated to convert due to the use of the i18n and 
> > static template tags and (under the old rendering scheme) a 
> > DjangoTemplates backend had to be available anyway for rendering the 
> > main admin templates. So I think JinjaTemplateRenderer may not be that 
> > useful in practice as it requires your project and all its third-party 
> > apps to provide Jinja2 templates for all widgets. 
> > 
> > I used these steps to use Jinja2 and allow the admin to continue using 
> > DjangoTemplates: 
> > 1. Prepend this to the default settings.TEMPLATES: 
> >  { 
> >         'BACKEND': 'django.template.backends.jinja2.Jinja2', 
> >         'APP_DIRS': True, 
> > } 
> > 2. Add 'django.forms' to INSTALLED_APPS. 
> > 3. Add settings.FORM_RENDERER = 
> > 'django.forms.renderers.templates.ProjectTemplateRenderer' 
>
> Makes sense. I still think we may as well provide JinjaTemplateRenderer, 
> for completeness, and because not all projects use the admin. But the 
> docs should be clear about the limitations, and point to 
> ProjectTemplateRenderer for more flexible setups. 
>
> Let me know once you have a PR that you feel is ready for review, happy 
> to review it. 
>
> Carl 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a0231f5f-5ce4-449e-bab8-2edf7bf05b05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to