Advertisement
avaaren

sdfds

May 28th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. # Serializer
  2.  
  3. class PinnedAppsSerizalazer(serializers.Serializer):
  4. app = serializers.ListField(
  5. child=serializers.CharField()
  6. )
  7.  
  8.  
  9. # View
  10. class PinnedAppView(APIView):
  11.  
  12. def get(self, request):
  13. pinned_apps = ['a', 'b', 'c', 'd']
  14. serializer = PinnedAppsSerizalazer(pinned_apps, many=True)
  15. return Response(serializer.data)
  16.  
  17. # Error
  18. Exception Type: AttributeError
  19. Exception Value:
  20. Got AttributeError when attempting to get a value for field `app` on serializer `PinnedAppsSerizalazer`.
  21. The serializer field might be named incorrectly and not match any attribute or key on the `str` instance.
  22. Original exception text was: 'str' object has no attribute 'app'.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement