Logging requests to django-rest-framework

后端 未结 8 715
迷失自我
迷失自我 2020-12-02 12:31

For debugging purposes, I would like to use Django\'s logging mechanism to log each and every incoming request when it \"arrives\" at django-rest-framework\'s doorstep.

8条回答
  •  再見小時候
    2020-12-02 12:56

    Override the APIView.initial() method to add logging yourself.

    Dispatch methods

    The following methods are called directly by the view's .dispatch() method. These perform any actions that need to occur before or after calling the handler methods such as .get(), .post(), put(), patch() and .delete().

    .initial(self, request, *args, **kwargs)
    Performs any actions that need to occur before the handler method gets called. This method is used to enforce permissions and throttling, and perform content negotiation.

提交回复
热议问题