how to display an error message over the field in django administration
I want to display an error message if the field is blank. At the moment, I
know how to bring ValidationError early in the page, but I need to get the
message right above the blank field. How can this be done?
have not yet been able to find an answer.
class Article(models.Model):
...
title_ru = models.CharField(max_length=255, blank=True)
...
class ArticleAdmin(admin.ModelAdmin):
class form(forms.ModelForm):
class Meta:
model = models.Article
def clean(self):
cleaned_data = super(forms.ModelForm, self).clean()
title_ru = cleaned_data['title_ru']
if not title_ru:
raise forms.ValidationError("Title ru")
return self.cleaned_data
forms.ValidationError("Title ru") displays a message at the top of the
page, but I need this message over the field
how to get the message out over the field Title_ru ?
No comments:
Post a Comment