download - 金字塔力下载生成文件
问题描述
我需要从金字塔应用程序中导出 GPX 文件。我已经在 jinja2 中准备了 gpx 模板,它工作正常,但是现在,我想提供给用户下载,而不是在浏览器中显示文件。怎么做 ?
解决方案
我找到了解决方案:
response = render_to_response( <template>, <data>, request=request)
response.content_type = 'application/gpx+xml'
response.content_disposition = 'attachment; filename="file.gpx"'
return response
推荐阅读
- python-3.x - cx_Freeze 应用程序立即关闭,没有错误
- cherrypy - 在多核服务器上复制cherrypy进程
- java - 在java中通过0截距求解最小二乘回归和强制
- javascript - React:“react-scripts start”找不到模块 webpack
- dart - 颤振以使用一个布尔变量启用和禁用各种 Check_List_Tile
- c - 如何为长信号和长核卷积编写 C 代码
- php - PHP-FPM 只对子域慢
- python - fromtimestamp 返回不同的结果
- javascript - 生成二维码的算法是否涉及随机性
- extjs - Extjs 5.1 中的路由器