Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for FileUploadParser with version 3.x #2399

merged 1 commit into from Jan 12, 2015


Copy link

@askholme askholme commented Jan 10, 2015

Output from parsers ends up in a Django MergeDict and they exists elements to be dicts - not None

Right now if FileUploadParser is used then trying to access['file'] will give ** TypeError: 'NoneType' object has no attribute 'getitem'

Making sure that the data part is an empty dict fixes this

Output from parsers ends up in a Django MergeDict and they exists elements to be dicts - not None
Copy link

tomchristie commented Jan 12, 2015

Looks reasonable, but I'm uncertain why we havn't seen any issues raised before if this is currently broken - is it newly broken in 3.x? If not it'd be super surprising as FileUploadParser has been part of the library for quite a while now.

Copy link
Contributor Author

askholme commented Jan 12, 2015

Can't tell as i just started using the framework.

Do note that i'm using the parser for a custom method on a viewset access directly as per below. This gives an error because is a mergedict where __getitem__ loops over the underlying dicts and then tries to use __getitem__ on the None returned from FileUploadParser.

Maybe the serializers use another method for access FileUploadParser data?

@list_route(methods=['put'],permission_classes=[permissions.IsAuthenticated],parser_classes=   [FileUploadParser])
    def raw(self,request):
        img = Image(['file'],user=self.request.user)
        return Response(ImageSerializer(img).data)

@tomchristie tomchristie added this to the 3.0.4 Release milestone Jan 12, 2015
tomchristie added a commit that referenced this issue Jan 12, 2015
Fix for FileUploadParser with 3.x
@tomchristie tomchristie merged commit fb0a434 into encode:master Jan 12, 2015
1 check passed
@tomchristie tomchristie changed the title Make FileUploadParser work with standard django API Fix for FileUploadParser with version 3.x Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants