Reputation: 325
these are fields of the model form class Meta:
model = Employee
exclude = ('user', 'created_by', 'is_deleted', 'created')
theses are the widgets
widgets = {
'first_name': forms.TextInput(attrs={'placeholder': _('First name')}),
'last_name': forms.TextInput(attrs={'placeholder': _('Last name')}),
'house_name': forms.TextInput(attrs={'placeholder': _('House name / flat No')}),
'street_name': forms.TextInput(attrs={'placeholder': _('Street Name / No')}),
'locality_name': forms.TextInput(attrs={'placeholder': _('Locality Name / No')}),
'pin_code': forms.TextInput(attrs={'placeholder': _('Zip Code')}),
}
Upvotes: 1
Views: 1663
Reputation: 1986
Error messages are not placed inside widgets
class MyForm(forms.ModelForm):
class Meta:
model=Employee
exclude = ('user', 'created_by', 'is_deleted', 'created')
error_messages = {
'first_name': {
'max_length': _("This writer's name is too long."),
},
}
Upvotes: 2
Reputation: 1714
From the documentation, you can simply use error_messages
for that;
'first_name': forms.TextInput(error_messages={'required': 'message'},
attrs={'placeholder': _('First name')})
Upvotes: 1