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
18
19
20
21
import django

INSTALLED_APPS = [
    "django.forms",
    # ...
]

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

FORM_RENDERER = "django.forms.renderers.TemplatesSetting"

Tips and Tricks Programming Development Django 5.x Django 4.2 Django 3.2