John
John

Reputation: 155

Get modelform to output custom name for modelform fields

I have a modelform:

class SubmitDomain(ModelForm):
    emailVerified = forms.CharField(max_length=50, required=False, widget=forms.TextInput(attrs={'class': 'validate', 'id': 'emailVerified'}))
    domainNm = forms.CharField(max_length=40, required=False, widget=forms.TextInput(attrs={'class': 'validate', 'id': 'domainNm'}))

In versions of django before 2+ I was able to just create verbose_name=something to change the display value of a modelform's field name different from what the model's field name actually is.

For example, on my form it displays: domainNm and emailVerified

How can I get it to display: Domain Name Verifying Email

Thank you in advance.

Upvotes: 0

Views: 150

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

verbose_name is an an attribute of model fields, not form fields. For forms you use label. Neither of these have changed in Django 2.

Upvotes: 1

Related Questions