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):
8484 if type (settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE ) is int :
8585 self .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE = settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE
8686
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+
8793 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 )
8897
8998 # Run only if logger is enabled.
9099 if self .DRF_API_LOGGER_DATABASE or self .DRF_API_LOGGER_SIGNAL :
You can’t perform that action at this time.
0 commit comments