From f44919b6b173991dc6c57e0159ec3fcb1ca776a8 Mon Sep 17 00:00:00 2001 From: ashnaaseth2325-oss Date: Wed, 18 Mar 2026 11:08:27 +0000 Subject: [PATCH] fix: handle Channel.DoesNotExist in remove_self viewset Signed-off-by: ashnaaseth2325-oss --- contentcuration/contentcuration/viewsets/user.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contentcuration/contentcuration/viewsets/user.py b/contentcuration/contentcuration/viewsets/user.py index bfacd08f2f..ea493fec3a 100644 --- a/contentcuration/contentcuration/viewsets/user.py +++ b/contentcuration/contentcuration/viewsets/user.py @@ -333,8 +333,9 @@ def remove_self(self, request, pk=None): if not channel_id: return HttpResponseBadRequest("Channel ID is required.") - channel = Channel.objects.get(id=channel_id) - if not channel: + try: + channel = Channel.objects.get(id=channel_id) + except Channel.DoesNotExist: return HttpResponseNotFound("Channel not found {}".format(channel_id)) if request.user != user and not request.user.can_edit(channel_id):