Skip to content

Commit d063669

Browse files
Adil Naimikorfuri
authored andcommitted
fix middleware process response template_name based on #28
1 parent d8088e6 commit d063669

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

django_prometheus/middleware.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ def process_view(self, request, view_func, *view_args, **view_kwargs):
141141
name, transport, method).inc()
142142

143143
def process_template_response(self, request, response):
144-
responses_by_templatename.labels(str(
145-
response.template_name)).inc()
144+
if hasattr(response, 'template_name'):
145+
responses_by_templatename.labels(str(
146+
response.template_name)).inc()
146147
return response
147148

148149
def process_response(self, request, response):

0 commit comments

Comments
 (0)