File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
drf_api_logger/middleware Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,16 @@ def __init__(self, get_response):
84
84
if type (settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE ) is int :
85
85
self .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE = settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE
86
86
87
+ def is_static_or_media_request (self , path ):
88
+ static_url = getattr (settings , 'STATIC_URL' , '/static/' )
89
+ media_url = getattr (settings , 'MEDIA_URL' , '/media/' )
90
+
91
+ return path .startswith (static_url ) or path .startswith (media_url )
92
+
87
93
def __call__ (self , request ):
94
+ # Skip logging for static and media files
95
+ if self .is_static_or_media_request (request .path ):
96
+ return self .get_response (request )
88
97
89
98
# Run only if logger is enabled.
90
99
if self .DRF_API_LOGGER_DATABASE or self .DRF_API_LOGGER_SIGNAL :
You can’t perform that action at this time.
0 commit comments