mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #26504 -- Avoided logging "Not Found" warnings if a middleware handles the 404.
For example, this avoids a warning in the case of a request that's redirected to a language-prefixed URL by LocaleMiddleware.
This commit is contained in:
@@ -179,10 +179,6 @@ class BaseHandler(object):
|
||||
response_is_rendered = True
|
||||
|
||||
except http.Http404 as exc:
|
||||
logger.warning(
|
||||
'Not Found: %s', request.path,
|
||||
extra={'status_code': 404, 'request': request},
|
||||
)
|
||||
if settings.DEBUG:
|
||||
response = debug.technical_404_response(request, exc)
|
||||
else:
|
||||
@@ -246,6 +242,12 @@ class BaseHandler(object):
|
||||
if not response_is_rendered and callable(getattr(response, 'render', None)):
|
||||
response = response.render()
|
||||
|
||||
if response.status_code == 404:
|
||||
logger.warning(
|
||||
'Not Found: %s', request.path,
|
||||
extra={'status_code': 404, 'request': request},
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
def process_exception_by_middleware(self, exception, request):
|
||||
|
||||
Reference in New Issue
Block a user