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