From 0b55ae8b2aa67f62d23ccb4063026bcb8f6b93e7 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Mon, 19 May 2025 21:37:47 +0330 Subject: [PATCH] categorys slider view --- backend/product/urls.py | 3 ++- backend/product/views.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/product/urls.py b/backend/product/urls.py index b5c8fd5..59cc686 100644 --- a/backend/product/urls.py +++ b/backend/product/urls.py @@ -1,10 +1,11 @@ from django.urls import path -from .views import AllCategories, ProductView, AllProductsView, CommentView, ShowCaseProductsView +from .views import AllCategories, ProductView, AllProductsView, CommentView, ShowCaseProductsView, ShowCaseCategoryListView urlpatterns = [ path('', AllProductsView.as_view(), name='category-products'), path('slider_category', ShowCaseProductsView.as_view(), name='category-products'), path('categories', AllCategories.as_view(), name='all-categories'), + path('slider_categories', ShowCaseCategoryListView.as_view(), name='all-categories'), path('', ProductView.as_view(), name='product-detail'), path('comments/', CommentView.as_view(), name='comment-views'), ] \ No newline at end of file diff --git a/backend/product/views.py b/backend/product/views.py index c8e978c..a1d873a 100644 --- a/backend/product/views.py +++ b/backend/product/views.py @@ -14,6 +14,7 @@ from order.serializers import OrderItemSerailzier from order.models import OrderModel from django.db.models import Min, Max from home.models import ShowCaseSlider +from home.serializers import ShowCaseSliderSerialzier # class APIView(APIView): # def __init__(self, *args, **kwargs): # super().__init__(*args, **kwargs) @@ -206,6 +207,16 @@ class AllProductsView(APIView): return Response({"detail": "Category not found."}, status=status.HTTP_404_NOT_FOUND) +class ShowCaseCategoryListView(APIView): + serializer_class = ShowCaseSliderSerialzier + permission_classes = [AllowAny] + def get(self, request): + categoryes = ShowCaseSlider.objects.all() + categoryes_ser = self.serializer_class(instance=categoryes, many=True, context={'request': request}) + return Response(categoryes_ser.data, status=status.HTTP_200_OK) + + + class ShowCaseProductsView(APIView): serializer_class = DynamicProductSerializer