This is the error I am getting: The view extraio.file_uploader.views.Upload_File didn't return an HttpResponse object.
Can anyone see what I’m doing wrong here? I can’t seem to figure out why I would be getting that exception since I am returning an HttpResponseRedirect.
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from models import Files
from forms import Upload_File_Form
def Upload_File(request):
if request.method == 'POST':
form = Upload_File_Form(request.POST, request.FILES)
if form.is_valid():
for f in request.FILES.get_list('file'):
f.save()
orgfilename = Files(orgname=f.name)
orgfilename.save()
return HttpResponseRedirect('success.html')
else:
form = Upload_File_Form()
return render_to_response('upload.html', {'form': form})
You returning your
HttpResponseobject only onPOSTrequest.Rewrite your view like this
EDIT: BTW you forgot to set
context_instancein yourender_to_responseAlso you can use
renderinsteadrequest.FILES.get_list('file')should berequest.FILES.getlist('file')