推荐学习书目
› 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
ns2250225
V2EX  ›  Python

关于 django channels 的一个 BUG,求大神指点

  •  
  •   ns2250225 ·
    ns2250225 · Mar 8, 2018 · 2274 views
    This topic created in 3130 days ago, the information mentioned may be changed or developed.

    使用 django channels 前

    • 前端请求的 header 里面,我设置了一个字段 X_USERNAME
    • django 后端可以通过 request.META.get('X_USERNAME') 获取到相应的值

    使用 django channels 后

    • django 后端通过 request.META,里面根本没有了 X_USERNAME 这个 KEY

    • 求大神指点,ORZ

    1 replies  •  2018-03-09 17:08:43 +08:00
    ns2250225
        1
    ns2250225  
    OP
       Mar 9, 2018
    = =,自己解决了,前端的请求头里面不要用自定义的 X_USERNAME,而要用 Authorization,这样设置之后,后端用 request.META.get('HTTP_AUTHORIZATION')就能拿到值了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2263 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 06:03 · PVG 14:03 · LAX 23:03 · JFK 02:03
    ♥ Do have faith in what you're doing.