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):