コード例 #1
0
ファイル: views.py プロジェクト: vlidu/fTournamentAPI
 def post(self, request, format=None):
     """
     Create new player
     ---
     request_serializer: PlayerSerializer
     response_serializer: PlayerSerializer
     """
     serializer = PlayerSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #2
0
ファイル: views.py プロジェクト: vlidu/fTournamentAPI
 def put(self, request, pk=None, slug=None, format=None):
     """
     Update selected player details
     ---
     request_serializer: PlayerSerializer
     response_serializer: PlayerSerializer
     """
     player = Players.get_player(pk, slug)
     serializer = PlayerSerializer(player, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     else:
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)