我试图在我的视图中提供一个文本文件,我似乎无法让Django尊重文本文件中的换行符。该代码是:如何防止Django的响应框架剥离文本文件的换行符?
response = TemplateResponse(request, template='dashboard/email_template.txt', mimetype='text/plain', status=200)
response['Content-Disposition'] = 'attachment; filename=mail_template.txt'
return response
和文件看起来是这样的:
key : {{ user.profile.secret_key }} # secret key
message: blah blah # Your message
当服务下载该文件时,两条线连接起来......当我打开该模板(email_template.txt)使用任何浏览器,文本编辑器或IDE,换行符都受到尊重。
是什么让Django(如果这与Django有什么关系?)连接这些行,我该如何防止它?
在此先感谢!
线条显示为串联在哪里? – 2012-03-26 21:05:52
在下载的文件中 – LaundroMat 2012-03-26 21:09:21
...你在哪个程序中查看它们显示为串联的位置? – 2012-03-26 21:10:29