From 3ecc84a83c7204778e3d3f7dde5e669ac63906e7 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 19 Oct 2010 00:26:15 +0000 Subject: [PATCH] Added a logging call on HTTP 405 for class-based views. This is for consistency with function-based views. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14273 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/generic/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/views/generic/base.py b/django/views/generic/base.py index d9d24a39de..19d041582c 100644 --- a/django/views/generic/base.py +++ b/django/views/generic/base.py @@ -60,7 +60,7 @@ class View(object): return view def dispatch(self, request, *args, **kwargs): - # Try to dispatch to the right method for that; if it doesn't exist, + # Try to dispatch to the right method; if a method doesn't exist, # defer to the error handler. Also defer to the error handler if the # request method isn't on the approved list. if request.method.lower() in self.http_method_names: @@ -74,6 +74,12 @@ class View(object): def http_method_not_allowed(self, request, *args, **kwargs): allowed_methods = [m for m in self.http_method_names if hasattr(self, m)] + logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path), + extra={ + 'status_code': 405, + 'request': self.request + } + ) return http.HttpResponseNotAllowed(allowed_methods)