views:

20

answers:

1

Hello Djangoists,

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.

Should I look into adding method at runtime in Python ?

+1  A: 

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/

Dominik Szopa