diff --git a/sapl/crud/base.py b/sapl/crud/base.py index b70e7a54a..f33d610d5 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -840,6 +840,22 @@ class CrudDeleteView(PermissionRequiredContainerCrudMixin, def get_success_url(self): return self.list_url + def delete(self, request, *args, **kwargs): + try: + super(CrudDeleteView, self).delete(request, args, kwargs) + except models.ProtectedError as err: + error_msg = 'Registro não pode ser removido, pois\ + é referenciado por outros registros:
\ + ' + + messages.add_message(request, + messages.ERROR, + error_msg) + return self.render_to_response(self.get_context_data()) + class Crud: BaseMixin = CrudBaseMixin