i would like to control when it's possible to delete elements in django admin. first, i tried to override the delete method of models to raise integrity error. it's work but this exception in not catch by admin and don't show a nice message. in fact, if you run in production mode, all that it say is " a problem has occurred".
secondly, i put a form and the clean method. it don't work either. the clean method is run whenever you modify the element. not only when you delete.
so how to have a way to control deleting of element in django admin (and have a nice message saying why you can't delete it )?
preguntado el 09 de septiembre de 13 a las 23:09
No need, to show a message, the delete buttons won't show as long you use this:
class MyAdmin(ModelAdmin): ... def has_delete_permission(self, request, obj=None): return False