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

Make it work in newer Django Versions #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ajaxuploader/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down