Unsaved File Objects may not have a .url attribute. by ar45 · Pull Request #2759 · encode/django-rest-framework (original) (raw)

I'm unsure how this should behave.
basically accessing the serializer.data with a FileField value of InMemoryUploadedFile raises FileField 'InMemoryUploadedFile' object has no attribute 'url'

This example does not provide any special use case, but I guess this should always provide the same behavior no matter what the setting of 'UPLOADED_FILES_USE_URL': False|True

class FileSerializer(serializers.Serializer): file = serializers.FileField()

class MyView(views.APIView): def post(request, **kwargs): s = FileSerializer(data=request.data) if s.is_valid(): return Response(data=serializer.data) return Response(data=serializer.errors)

AttributeError at /api/files
'InMemoryUploadedFile' object has no attribute 'url'