@@ -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 :
@@ -155,6 +164,7 @@ def __call__(self, request):
155164 "application/vnd.api+json" ,
156165 "application/gzip" ,
157166 "application/octet-stream" ,
167+ "text/calendar" ,
158168 ]
159169 if hasattr (settings , "DRF_API_LOGGER_CONTENT_TYPES" ) and type (
160170 settings .DRF_API_LOGGER_CONTENT_TYPES
@@ -170,6 +180,9 @@ def __call__(self, request):
170180 response_body = '** Binary File **'
171181 elif getattr (response , 'streaming' , False ):
172182 response_body = '** Streaming **'
183+ elif response .get ('content-type' ) == 'text/calendar' :
184+ response_body = '** Calendar **'
185+
173186 else :
174187 if type (response .content ) is bytes :
175188 response_body = json .loads (response .content .decode ())
0 commit comments