Fix django middleware and new decorator

Django middleware needs to always return a response (I missed an error case).

Added a convenient decorator for wrapping a function in a context.