'django ValidationError in admin save_model

Models.py

class user(AbstractUser):
    salary_number = models.IntegerField(unique=True, null=True, blank=True)    

Admin.py

def save_model(self, request, obj, form, change):
    if obj.salary_number == None:
        raise ValidationError("ERROR salary number!")
    ....
    obj.save()

I'm trying to show error for user if they forget to fill salary number, but I got error ValidationError at /admin/information/user/add/. How can I fixed that?

I have a reason to not set salary_number null & blank = False.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source