I am writting an API on Django Rest Framework to follow users. I define a method POST method to follow, but a body is required. I want to do without body or a default body. If I replace POST with GET works, If is it possible and how can I do?
class UserProfileViewSet(ModelViewSet):
serializer_class = UserProfileSerializer
queryset = UserProfile.objects.all()
filter_backends = (filters.SearchFilter,)
search_fields = ('name', 'email')
permission_classes = (UpdateOwnProfile,)
@action(methods=['POST'], detail=True, url_path='follow')
def follow(self, request, pk=None):
user_to_follow = UserProfile.objects.get(pk=pk)
request.user.add_relationship(
user_to_follow, RELATIONSHIP_FOLLOWING)
return Response([], status=status.HTTP_200_OK)