Using a decorator I was trying to add a method to WSGIRequest request, just like is_ajax(). Since I could not find a proper way I just updated request.META with the info needed开发者_如何学Python.
Should I look into adding method at runtime in Python ?
You can try to write custom middleware and add this method to request during request process.
See this for more info how to write middleware:
http://docs.djangoproject.com/en/dev/topics/http/middleware/#writing-your-own-middleware
http://www.djangobook.com/en/beta/chapter16/
精彩评论