[Django]-Change label of a form field Django

9👍

Within the AuthorForm class you can set the labels attribute which is a dictionary maps field name to label.

class InventoryModelForm(forms.ModelForm):
    class Meta:
        model = Inventory
        fields = ['watercourse',]
        widgets = {
            'watercourse': forms.TextInput(attrs={
                'class': 'form-control',
                'placeholder': 'lorem ipsum',
            }),
        }
        labels = {
            'watercourse': 'Insert a watercourse',
        }

1👍

you can do this:

class Meta:

labels = {
        'name': 'LabelName',
    }

0👍

In forms.py try

labels = {
        'name': _('Writer'),
    }

Leave a comment