From dec22cbbb5fc1f1638e178732404b4a0da3f8ad3 Mon Sep 17 00:00:00 2001 From: Paul Wachendorf Date: Mon, 9 Dec 2019 17:00:31 +0100 Subject: [PATCH] added check of type returned by request.FILES.values() in _ajax_upload... in newer django versions its a generator --- ajaxuploader/views/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ajaxuploader/views/base.py b/ajaxuploader/views/base.py index 67e5f4d..6ab8dc1 100644 --- a/ajaxuploader/views/base.py +++ b/ajaxuploader/views/base.py @@ -3,6 +3,8 @@ except ImportError: from django.utils import simplejson as json +import types + from django.core.files.base import File from django.core.serializers.json import DjangoJSONEncoder @@ -48,7 +50,13 @@ def _ajax_upload(self, request, *args, **kwargs): # that each upload is a separate request, so FILES should # only have one entry. Thus, we can just grab the first # (and only) value in the dict. - upload = request.FILES.values()[0] + values = request.FILES.values() + if isinstance(values, list): + upload = values[0] + elif isinstance(values, types.GeneratorType): + upload = values.__next__() + else: + raise NotImplementedError('unknown FILES type') else: raise Http404("Bad Upload") filename = upload.name