def delete(self, request, *args, **kwargs):
        # Get the object to delete
        obj = get_object_or_404(
            self.form_class.Meta.model, pk=kwargs.get('pk', 0)
        )

        try:
            view = super(BaseDeleteView, self).delete(request, *args, **kwargs)
        except __HOLE__, e:
            messages.error(request, "Error: {0}".format(' '.join(e.messages)))
            return redirect(obj)

        messages.success(request, "Deletion Successful")
        return view
dataset/ETHPy150Open mozilla/inventory/base/views.py/BaseDeleteView.delete