I would like to know how to show an error message in the Django admin.
I have a private user section on my site where the user can create requests using “points”. A request takes 1 or 2 points from the user’s account (depending on the two type of request), so if the account has 0 points the user cant make any requests… in the private user section all this is fine, but the user can also call the company and make a request by phone, and in this case I need the admin to show a custom error message in the case of the user points being 0.
Any help will be nice 🙂
Thanks guys
One way to do that is by overriding the ModelForm for the admin page. That allows you to write custom validation methods and return errors of your choosing very cleanly. Like this in admin.py:
Hope that helps!