V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
shoumu
V2EX  ›  Python

django 返回 pdf,其它机器上无法下载

  •  
  •   shoumu ·
    shoumu · 2014-04-23 23:44:24 +08:00 · 2743 次点击
    这是一个创建于 3648 天前的主题,其中的信息可能已经有所发展或是发生改变。
    具体是这样子的,在服务器上用django上面通过下面的代码返回一个pdf
    response = HttpResponse(content_type='application/pdf')
    response.write(pdf)
    return response

    现在在我的电脑上能够得到这个pdf,其它电脑上却不能够,请问这是为什么?
    第 1 条附言  ·  2014-04-24 12:54:43 +08:00
    已经解决,是我用ajax把数据post上去了,数据返回给了ajax。用form提交即可
    3 条回复    2014-04-30 00:29:21 +08:00
    manoon
        1
    manoon  
       2014-04-24 00:48:45 +08:00
    编码,或者浏览器。
    shoumu
        2
    shoumu  
    OP
       2014-04-24 10:57:54 +08:00
    @manoon 经验证是我装了IDM让我的机器能够下载的,去掉就不能了。
    但是我的浏览器中能够获得相应的数据,就是无法弹出提示下载的框
    cloudream
        3
    cloudream  
       2014-04-30 00:29:21 +08:00
    response['Content-Disposition'] = 'filename="somefilename.pdf"'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5235 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:42 · PVG 15:42 · LAX 00:42 · JFK 03:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.