Greeting i'm trying to customise the ValidationError message i got this "veuillez renseigner ce champ" as a toolip under the input field my web site is in other language and already setup in settings.py this is my forms.py
class OrganismForm(forms.ModelForm):
class Meta:
model = Organism
fields = ['code', 'name', 'parent', 'region']
exclude = []
widgets = {
'code': forms.TextInput(attrs={'class': 'form-control form-control-outline',
'placeholder':'Placeholder' ,
'data-listener-added_b000d9d8':'true'}),
'name': forms.TextInput(attrs={'class': 'form-control form-control-outline',
'placeholder':'Placeholder' ,
'data-listener-added_b000d9d8':'true'}),
'parent': forms.Select(attrs={'class': 'select select2-hidden-accessible',
}),
'region': forms.Select(attrs={'class': 'select select2-hidden-accessible',
}),
}
localized_fields = None
labels = {}
help_texts = {}
error_messages = {}
def __init__(self, *args, **kwargs):
return super(OrganismForm, self).__init__(*args, **kwargs)
def is_valid(self):
return super(OrganismForm, self).is_valid()
def full_clean(self):
return super(OrganismForm, self).full_clean()
def clean_code(self):
code = self.cleaned_data.get("code", None)
return code
def clean_name(self):
name = self.cleaned_data.get("name", None)
if not name:
raise ValidationError('custom text message.')
return name
def clean_parent(self):
parent = self.cleaned_data.get("parent", None)
return parent
def clean_region(self):
region = self.cleaned_data.get("region", None)
return region
def clean(self):
return super(OrganismForm, self).clean()
def validate_unique(self):
return super(OrganismForm, self).validate_unique()
def save(self, commit=True):
return super(OrganismForm, self).save(commit)
Please don't use Trac as a support channel. If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.