def promote(self, request, pk=None): game = Game.objects.get(pk=pk) if not game.is_my_turn(request.user): return Response("not your turn", status=status.HTTP_400_BAD_REQUEST) chess = Chess(game.data) chess.promote((request.data['row'], request.data['column']), request.data['name']) # update db with new board game.data = chess.export() game.save() return Response("success, time to refresh")