Skip to content

Commit

Permalink
add some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
guel-codes authored and rtpg committed Oct 9, 2024
1 parent 667fa4b commit f19f804
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions taggit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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")

0 comments on commit f19f804

Please sign in to comment.