how to use the GlobalRequestMiddleware strategy?
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?
精彩评论