[Fixed]-Django email, name โ€“ not null, not empty, without default

1๐Ÿ‘

โœ…

Add a clean() method to your model where you validate all the fields you need to validate and raise ValidationError if something is wrong.

class users(models.Model):
    ...

    def clean(self):
        if not is_valid_surname(self.surname):
            raise ValidationError({'surname': _('Invalid surname.')})
        ...

The docs are here.

๐Ÿ‘คC14L

Leave a comment