Django 1.11 built-in and custom widget template locations
I am trying to write a custom "new way" widget using the Django 1.11 new / widget render function and I am very confused by the lack of examples and well, no documentation:
From the Django docs :
Each widget has a template_name attribute with a value like input.html. Built-in widget templates are stored in the django / forms / widgets path. You can create your own template for input.html by defining, for example, django / forms / widgets / input.html.
It is not clear where it refers. Does this mean that in my directory venv/lib/python2.7/site-packages/django/forms/
I have to create a new directory called widgets/
and place my templates there? Because it doesn't make sense. Or should I create a django / forms / widgets / directory in my projects directory and place my new templates there?
source to share
You shouldn't add, remove or modify files in the Django installation directory venv/lib/python2.7/site-packages/django
.
To override django/forms/widgets/input.html
, you must create a file django/forms/widgets/input.html
in one of your template directories. Your template directories depend on the parameter TEMPLATES
.
source to share