From 202369e189abc6dc809dbc473fda4be01ac891fd Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 9 Feb 2021 13:40:40 +0000 Subject: [PATCH] added empty action "related" to ProductViewSet --- products/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/products/views.py b/products/views.py index a318bcb..6954268 100644 --- a/products/views.py +++ b/products/views.py @@ -12,7 +12,7 @@ from django.db.models import Q from rest_framework import viewsets from rest_framework.response import Response from rest_framework.permissions import IsAuthenticatedOrReadOnly, IsAdminUser, IsAuthenticated -from rest_framework.decorators import api_view, permission_classes +from rest_framework.decorators import api_view, permission_classes, action import requests @@ -41,6 +41,11 @@ class ProductViewSet(viewsets.ModelViewSet): def perform_create(self, serializer): serializer.save(creator=self.request.user) + @action(detail=True, methods=['GET',]) + def related(request): + # find the most similar products + return Response(data=[]) + @api_view(['GET',]) @permission_classes([IsAuthenticated,])