@@ -79,7 +79,16 @@ def __init__(self, get_response):
79
79
if type (settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE ) is int :
80
80
self .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE = settings .DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE
81
81
82
+ def is_static_or_media_request (self , path ):
83
+ static_url = getattr (settings , 'STATIC_URL' , '/static/' )
84
+ media_url = getattr (settings , 'MEDIA_URL' , '/media/' )
85
+
86
+ return path .startswith (static_url ) or path .startswith (media_url )
87
+
82
88
def __call__ (self , request ):
89
+ # Skip logging for static and media files
90
+ if self .is_static_or_media_request (request .path ):
91
+ return self .get_response (request )
83
92
84
93
# Run only if logger is enabled.
85
94
if self .DRF_API_LOGGER_DATABASE or self .DRF_API_LOGGER_SIGNAL :
@@ -150,6 +159,7 @@ def __call__(self, request):
150
159
"application/vnd.api+json" ,
151
160
"application/gzip" ,
152
161
"application/octet-stream" ,
162
+ "text/calendar" ,
153
163
]
154
164
if hasattr (settings , "DRF_API_LOGGER_CONTENT_TYPES" ) and type (
155
165
settings .DRF_API_LOGGER_CONTENT_TYPES
@@ -165,6 +175,9 @@ def __call__(self, request):
165
175
response_body = '** Binary File **'
166
176
elif getattr (response , 'streaming' , False ):
167
177
response_body = '** Streaming **'
178
+ elif response .get ('content-type' ) == 'text/calendar' :
179
+ response_body = '** Calendar **'
180
+
168
181
else :
169
182
if type (response .content ) is bytes :
170
183
response_body = json .loads (response .content .decode ())
0 commit comments