From 80575c31f8cc590b62bf80323537be2fdb7003d9 Mon Sep 17 00:00:00 2001 From: mohsentaba Date: Tue, 23 Dec 2025 09:52:55 +0330 Subject: [PATCH] category slug url updated . --- apps/hadis/docs.py | 6 +++--- apps/hadis/urls.py | 2 +- apps/hadis/views/hadis.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/hadis/docs.py b/apps/hadis/docs.py index 8a5f1ed..73632b8 100644 --- a/apps/hadis/docs.py +++ b/apps/hadis/docs.py @@ -300,12 +300,12 @@ hadis_list_swagger = swagger_auto_schema( tags=['Hadis'], manual_parameters=[ openapi.Parameter( - 'category_id', + 'category_slug', openapi.IN_PATH, description="Unique identifier of the Hadis category. Must be a valid category ID that exists in the system.", - type=openapi.TYPE_INTEGER, + type=openapi.TYPE_STRING, required=True, - example=1 + example='-330' ), openapi.Parameter( 'page', diff --git a/apps/hadis/urls.py b/apps/hadis/urls.py index 41449ca..a02725f 100644 --- a/apps/hadis/urls.py +++ b/apps/hadis/urls.py @@ -24,7 +24,7 @@ urlpatterns = [ path('categories/', CategoriesView.as_view(), name='categories'), # ← Least specific LAST # Hadis paths - path('category//', HadisListView.as_view(), name='hadis-list'), + path('category//', HadisListView.as_view(), name='hadis-list'), path('arguments/', HadisMainListView.as_view(), name='hadis-main-list'), # Narrator paths diff --git a/apps/hadis/views/hadis.py b/apps/hadis/views/hadis.py index 9bc09b6..e51a9ae 100644 --- a/apps/hadis/views/hadis.py +++ b/apps/hadis/views/hadis.py @@ -81,12 +81,12 @@ class HadisListView(ListAPIView): return self.list(request, *args, **kwargs) def get_queryset(self): - category_id = self.kwargs.get('category_id') - if not HadisCategory.objects.filter(id=category_id).exists(): + category_slug = self.kwargs.get('category_slug') + if not HadisCategory.objects.filter(slug=category_slug).exists(): return Hadis.objects.none() return Hadis.objects.filter( - category_id=category_id, + category__slug=category_slug, status=True ).order_by('number').annotate( # distinct=True is CRITICAL here.