About Overwritable Form FIeld Templates

By default, form field templates are taken from Django installation and third-party app directories, but the TEMPLATES setting is ignored. This is what to set in the settings to overwrite some of those templates with your project templates:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import django

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            os.path.join(BASE_DIR, "myproject", "templates"),
            django.__path__[0] + "/forms/templates",
        ],
        "APP_DIRS": True,
        "OPTIONS": {
            # ...
        },
    },
]

FORM_RENDERER = "django.forms.renderers.TemplatesSetting"

Tips and Tricks Programming Development Django 4.2 Django 3.2 Django 2.2