1

ファイルのダウンロード後に別のビューにリダイレクトしたいのですが、ダウンロードが終了しても何も起こらず、同じページに残ります。ダウンロードは完全に機能します。何か案が??

Views.py:

#The function that downloads the file
def download_file(path, format, fileName):

    path = path+"."+format          
    filename = os.path.basename(path)    
    mimetype, encoding = mimetypes.guess_type(filename)

    if fileName==None: fileName = filename
    else: fileName = fileName+"."+format

    response = HttpResponse(mimetype=mimetype)
    response['Content-Disposition'] = 'attachment; filename=%s' %fileName
    response.write(file(path, "rb").read())

    return response


def download_downloaded_track(request, downloadedTrack_id):

     dt = get_object_or_404(DownloadedTrack, id=downloadedTrack_id)

     if request.method=='POST':
         form = DownloadDownloadedTrackForm(request.POST)

         if form.is_valid():
             ...
             return download_file(downloadedTrackRoute+dt.fileName,format, name)

             return HttpResponseRedirect(reverse('profile_detail'))            

    form = DownloadDownloadedTrackForm(initial={'format':'gpx'})
    return render(request,'principal/downloadedTrack.html',{'form':form,'zone':dt.zone,'downloadedTrack':dt, 'layer':'downloadDownloadedTrack'})
4

0 に答える 0