在提供静态文件后重定向

时间:2014-06-16 10:54:54

标签: python django

我有以下代码向用户提供静态文本文件

def download(request, param1, param2):
    filepath = /path/to/file
    fileName = 'filename.txt'
    fsock = open(filepath, 'r')
    response = StreamingHttpResponse(fsock, content_type='application/txt')
    response['Content-Disposition'] = "attachment; filename=%s" % \
                                     (fileName)
    return response

我有另一个视图,解析了一些表单后重定向

def sampleAPP(request, param1, param2):
    // Happens when user clicks the download button in the form
    ...
    ...
    // do some logic
    ...
    ...
    return HttpResponseRedirect('/download/')

问题是,现在我想向用户发送消息,"此文件已成功提供"在用户点击"下载"按钮。

但是当我访问下载视图时,它只是下载文件,我无法向用户返回任何消息。我如何实现这一目标?

感谢。

0 个答案:

没有答案