categorys slider view
This commit is contained in:
@@ -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('<int:pk>', ProductView.as_view(), name='product-detail'),
|
||||
path('comments/<int:pk>', CommentView.as_view(), name='comment-views'),
|
||||
]
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user