From 36284bae37128b2603983f4c5b2ff71b5d7fd62f Mon Sep 17 00:00:00 2001 From: Happy Felix Chukwuma Date: Fri, 29 Nov 2024 14:51:14 +0100 Subject: [PATCH] Updated HTTP status code for non-existent category --- server/apps/research/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/apps/research/views.py b/server/apps/research/views.py index 0212390..e131a0b 100644 --- a/server/apps/research/views.py +++ b/server/apps/research/views.py @@ -6,6 +6,8 @@ import uuid import logging from django.db import transaction +from rest_framework import serializers + from .models import Article, ArticleSlugHistory from .permissions import ArticleUserWritePermission @@ -108,7 +110,7 @@ def retrieve_by_category(self, request, category=None): return Response({'success': True, 'data': serializer.data}) except Exception as e: logger.error(f"Error retrieving articles by category: {e}") - return Response({'error': 'Category does not exist'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response({'error': 'Category does not exist'}, status=status.HTTP_404_NOT_FOUND) def is_valid_uuid(self, value): """Check if the value is a valid UUID."""