From aad6c5e022edae9bc14b8b17285bbcf04b8d5561 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Sun, 8 Sep 2024 02:07:21 +0600 Subject: [PATCH] updt: backend - get single book details api pk is replaced by book_code --- backend/book_api/urls/v1.py | 2 +- backend/book_api/views/v1.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/book_api/urls/v1.py b/backend/book_api/urls/v1.py index 3e2408c..e833f16 100644 --- a/backend/book_api/urls/v1.py +++ b/backend/book_api/urls/v1.py @@ -5,5 +5,5 @@ urlpatterns = [ path('', v1.BookView.as_view()), - path('/', v1.BookView.as_view()), + path('/', v1.BookView.as_view()), ] diff --git a/backend/book_api/views/v1.py b/backend/book_api/views/v1.py index 692a59d..de0162d 100644 --- a/backend/book_api/views/v1.py +++ b/backend/book_api/views/v1.py @@ -14,11 +14,11 @@ class BookView(APIView): permission_classes = [AllowAny] def get(self, request, *args, **kwargs): - pk = kwargs.get('pk', None) + book_code = kwargs.get('book_code', None) - if pk: + if book_code: try: - book = Book.objects.get(pk=pk, is_deleted=False) + book = Book.objects.get(book_code=book_code, is_deleted=False) except Book.DoesNotExist: raise NotFound(detail="Book not found.")