class RequestLogMiddleware(object):

    def process_request(self, request):
        request.start_time = time.time()

def process_response(self, request, response):
    if response['content-type'] == 'application/json':
        pass
Logging requests to django-rest-framework