Django overrides HTML form template template?

In my settings.py I have set

FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'

      

now you can add your own templates to:

<project>/templates/django/forms/widgets/

      

or

<app>/templates/django/forms/widgets/

      

it works great! However, what I can't find is where can I override the default html (form) label?

class TestForm(forms.Form):
    first_name = forms.CharField(label="First name", max_length=50)
    last_name = forms.CharField(label="Last name")
    nick_name = forms.CharField(required=False)

      

The above form will display the labels like this:

<label for="id_first_name">First name:</label>

      

I want to make the shortcut differently. So i thought it would be easy how to add html label template: templates / django / forms / widgets / label.html

This one doesn't work . Been going through the Django docs but I can't seem to find how to do this for the shortcuts. Apparently the shortcut is not a widget.

https://docs.djangoproject.com/en/1.11/ref/forms/widgets/#built-in-widgets

My question is where / how to change the default label?

+3


source to share





All Articles