开发者

how to use the GlobalRequestMiddleware strategy?

开发者 https://www.devze.com 2023-01-24 14:03 出处:网络
I\'m try开发者_运维技巧ing to use the GlobalRequestMiddleware strategy as described here.I have implemented the middleware exactly as written, and when I want to use it, I have

I'm try开发者_运维技巧ing to use the GlobalRequestMiddleware strategy as described here. I have implemented the middleware exactly as written, and when I want to use it, I have

from myapp.middeware.GlobalRequestMiddleware import get_request
request = get_request()

but get_request throws a KeyError. I have a feeling that the problem has something to do with how I'm importing get_request, as the _requests variable has two different ids in process_request and in get_request. (If I don't put the "import" statement in, python complains that "get_request is not defined")

Can someone clear up my confusion?


Have you actually installed the middleware in settings.py?

0

精彩评论

暂无评论...
验证码 换一张
取 消