added empty action "related" to ProductViewSet

This commit is contained in:
Sam
2021-02-09 13:40:40 +00:00
parent 94b62ce494
commit 202369e189

View File

@@ -12,7 +12,7 @@ from django.db.models import Q
from rest_framework import viewsets from rest_framework import viewsets
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticatedOrReadOnly, IsAdminUser, IsAuthenticated 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 import requests
@@ -41,6 +41,11 @@ class ProductViewSet(viewsets.ModelViewSet):
def perform_create(self, serializer): def perform_create(self, serializer):
serializer.save(creator=self.request.user) 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',]) @api_view(['GET',])
@permission_classes([IsAuthenticated,]) @permission_classes([IsAuthenticated,])