当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Django: how to add http header to responses in a convenient way?

问题描述:

I know we can use HttpResponseInstance['headername'] = 'headervalue' to add header to http response. But in this way, I have to rewrite all the generic view I am using, which makes much more work.

Is there a convenient way to add header to responses, like a callback for responses, or a url decorator?

网友答案:

You can write a middleware class and implement the method process_response.

分享给朋友:
您可能感兴趣的文章:
随机阅读: