1👍
✅
Field value in clean_
method is available as self.cleaned_data['field_name']
:
class MyModelForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ('title', )
def clean_title(self):
title = self.cleaned_data['title']
try:
name = client.search(title).name
except HTTPError:
raise ValidationError("Can't validate the name. Try again later")
if title != name:
raise ValidationError("This name is not supported")
return title
Source:stackexchange.com