From 7c9f6d7789a3eba501ca78c21fd0a706d4f7cd29 Mon Sep 17 00:00:00 2001 From: Miguel Johnson Date: Thu, 15 Aug 2024 01:26:35 -0400 Subject: [PATCH] add some error handling --- taggit/admin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/taggit/admin.py b/taggit/admin.py index 9470de14..1ab26989 100644 --- a/taggit/admin.py +++ b/taggit/admin.py @@ -87,6 +87,9 @@ def merge_tags_view(self, request): @admin.action(description="Remove orphaned tags") def remove_orphaned_tags_action(self, request, queryset): - orphaned_tags = Tag.objects.filter(taggit_taggeditem_items=None) - count, _ = orphaned_tags.delete() - self.message_user(request, f"Successfully removed {count} orphaned tags.", level="success") \ No newline at end of file + try: + orphaned_tags = Tag.objects.filter(taggit_taggeditem_items=None) + count, _ = orphaned_tags.delete() + self.message_user(request, f"Successfully removed {count} orphaned tags.", level="success") + except Exception as e: + self.message_user(request, f"An error occurred: {e}", level="error") \ No newline at end of file