I'd like to perform a check when saving a model via the django Admin panel. I thought about using ModelAdmin.save_model()
, however, from the documentation it says:
ModelAdmin.save_model() and ModelAdmin.delete_model() must save/delete the object, they are not for veto purposes, rather they allow you to perform extra operations.
I need to perform a check to enforce time constraints, only if the model is being edited and in some case, I need to NOT perform the save. (e.g. If it's past midnight and the admin is trying to edit a model instance, I don't want to save the changes, and alert the admin that it's past midnight...)
What would be the best place to do that considering that ModelAdmin.save_model cannot veto the saving operation?