I am seeing that there is data from the API for one of the returns I am expecting and it says Array(2), but then when you expand the response, it says Array(0).
Another set of data being serialized in the same way and sent back in the SAME response shows accurately...
Post any code you think might be relevant (one fenced block per file)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def game_detail(request, gamesession_id):
authentication_classes=[ SessionAuthentication ]
permission_classes=(IsAuthenticated,)
gamesession = GameSession.objects.get(id=gamesession_id)
game_questions = Question.objects.filter(id__in=gamesession.questions.values_list('id')).distinct()
# Grab the players associated with the game to send back in the response
game_players = Player.objects.filter(game=gamesession_id).distinct()
# game_players_two = Player.objects.get(game=gamesession_id)
# print(game_players_two)
game_users = User.objects.filter(id__in=gamesession.players.values_list('id')).distinct()
# Serialize the data
game_data = GameSessionSerializer(gamesession).data
question_data = QuestionSerializer(game_questions, many=True).data
player_data = PlayerSerializer(game_players, many=True).data
print('qd', question_data)
print('player_data !!!!!!!!', player_data)
print('gamedata', game_data)
user_data = UserSerializer(game_users, many=True).data
print('user data', user_data)
# Send it back to the client
return Response({ 'gameSession': game_data, 'gameQuestions': question_data, 'players': player_data, 'users': user_data })
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
I truly have no idea...the user data & player data looks the same to me in what's being sent to react, but then they are different when they arrive
this was definitely user error...had an array method I thought was acting on a copy of that array and I wasn't setting the state at that point so it wasn't on my radar!
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
DR
What's the problem you're trying to solve?
I am seeing that there is data from the API for one of the returns I am expecting and it says Array(2), but then when you expand the response, it says Array(0). Another set of data being serialized in the same way and sent back in the SAME response shows accurately...
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
I truly have no idea...the user data & player data looks the same to me in what's being sent to react, but then they are different when they arrive
What things have you already tried to solve the problem?
I added the auth classes just in case, it didn't change the response. I changed the Player serializer to this - serializers.HyperlinkedModelSerializer. No change.... https://stackoverflow.com/questions/73235402/serializing-model-queryset-showing-empty-ordereddict
Paste a link to your repository here https://github.com/estebbins/FareIsFair-Client https://github.com/estebbins/FareIsFair-API