首页 > 解决方案 > 金字塔力下载生成文件

问题描述

我需要从金字塔应用程序中导出 GPX 文件。我已经在 jinja2 中准备了 gpx 模板,它工作正常,但是现在,我想提供给用户下载,而不是在浏览器中显示文件。怎么做 ?

标签: downloadpyramid

解决方案


我找到了解决方案:

response = render_to_response( <template>, <data>, request=request)
response.content_type = 'application/gpx+xml'
response.content_disposition = 'attachment; filename="file.gpx"'
return response

推荐阅读