From 54a38bfb4312e2f03e487051daf19d54015b03a0 Mon Sep 17 00:00:00 2001 From: Dani Hodovic Date: Tue, 28 Jan 2020 10:55:09 +0100 Subject: [PATCH] Allow rendering custom widgets from root templates dir (#2356) * Allow rendering custom widgets from root templates dir Rendering custom widgets from the projects root template directory doesn't work out of the box. See: https://stackoverflow.com/questions/45844032/django-templatedoesnotexist-in-case-of-a-custom-widget/46208414#46-208414 This changes the setting to use the same template finding logic that the TEMPLATES setting uses. * update APP_DIRS=True * fixup! update APP_DIRS=True --- {{cookiecutter.project_slug}}/config/settings/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index ecfeed7a..42edac1f 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -68,6 +68,7 @@ DJANGO_APPS = [ "django.contrib.staticfiles", # "django.contrib.humanize", # Handy template tags "django.contrib.admin", + "django.forms", ] THIRD_PARTY_APPS = [ "crispy_forms", @@ -196,6 +197,10 @@ TEMPLATES = [ }, } ] + +# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer +FORM_RENDERER = "django.forms.renderers.TemplatesSetting" + # http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs CRISPY_TEMPLATE_PACK = "bootstrap4"