ContentNotRenderedError while using django middleware

前端 未结 2 1866
逝去的感伤
逝去的感伤 2021-01-23 03:21

I used process_request and process_response functions in django middleware in order to log the requests before hitting the viewset. But, I get Internal Server Error. I don\'t

2条回答
  •  臣服心动
    2021-01-23 04:28

    I fixed the issue. It's because the response object returned by process_response doesn't have actual response. I modified it to following and it worked.

    class MyMiddleware(): 
        def process_request( self, request ): 
            print "xxxxx"
            return None
        def process_response( self, request, response ): 
            print "xxxxx" 
            return response
    

提交回复
热议问题