I have this model I’m showing in the admin page:
class Dog(models.Model):
bark_volume = models.DecimalField(...
unladen_speed = models.DecimalField(...
def clean(self):
if self.bark_volume < 5:
raise ValidationError("must be louder!")
As you can see I put a validation on the model. But what I want to happen is for the admin page to show the error next to the bark_volume field instead of a general error like it is now. Is there a way to specify which field the validation is failing on?
Much thanks in advance.
OK, I figured it out from this answer.
You have to do something like this: