@@ -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 :
@@ -155,6 +164,7 @@ def __call__(self, request):
155
164
"application/vnd.api+json" ,
156
165
"application/gzip" ,
157
166
"application/octet-stream" ,
167
+ "text/calendar" ,
158
168
]
159
169
if hasattr (settings , "DRF_API_LOGGER_CONTENT_TYPES" ) and type (
160
170
settings .DRF_API_LOGGER_CONTENT_TYPES
@@ -170,6 +180,9 @@ def __call__(self, request):
170
180
response_body = '** Binary File **'
171
181
elif getattr (response , 'streaming' , False ):
172
182
response_body = '** Streaming **'
183
+ elif response .get ('content-type' ) == 'text/calendar' :
184
+ response_body = '** Calendar **'
185
+
173
186
else :
174
187
if type (response .content ) is bytes :
175
188
response_body = json .loads (response .content .decode ())
0 commit comments