I am trying to look up really nested information in my web app but keep getting Relation fields do not support nested lookups
as an error when doing so.
Serializers:
class UserSerializer(ModelSerializer):
class Meta(UserDetailsSerializer.Meta):
model = User
class UserProfileSerializer(ModelSerializer):
user = UserSerializer(required=True, many=False)
class Meta:
model = UserProfile
fields = ('premium', 'user')
class UserGameProfileSerializer(ModelSerializer):
user = UserProfileSerializer(required=True, many=False)
game = GameDetailSerializer(required=True, many=False)
class Meta:
model = UserGameProfile
fields = ('user', 'game', 'game_user_name')
View:
class UserGameProfileView(generics.ListAPIView):
# authentication_classes = (authentication.TokenAuthentication,)
# permission_classes = (permissions.IsAuthenticated,)
serializer_class = UserGameProfileSerializer
def get_queryset(self):
return UserProfile.objects.filter(user__user__username__exact=self.request.user)
My Logic
In my mind the query set would go from UserGameProfileSerializer -> UserProfileSerializer -> UserSerializer -> Username. Is that not the case? If so, why is it not allowed?
Aucun commentaire:
Enregistrer un commentaire