cómo controlar la eliminación en django_admin
Frecuentes
Visto 135 veces
0
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 )?
1 Respuestas
0
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
Respondido el 10 de Septiembre de 13 a las 04:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas django django-admin or haz tu propia pregunta.