diff options
| author | sobolevn <mail@sobolevn.me> | 2025-10-12 23:09:46 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-12 22:09:46 +0200 |
| commit | 0f75f8f1ff2078cde3c1701851c754b91c6baf44 (patch) | |
| tree | 0ddb87c80be0b8218a098deba43a8cc8a0fc2a67 | |
| parent | 315dbe675df338ae66c8fa43274a76ecbed7ef67 (diff) | |
Optimized View.dispatch() a bit.
| -rw-r--r-- | django/views/generic/base.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/django/views/generic/base.py b/django/views/generic/base.py index 485b74d377..a961dfddee 100644 --- a/django/views/generic/base.py +++ b/django/views/generic/base.py @@ -136,10 +136,9 @@ class View: # 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: - handler = getattr( - self, request.method.lower(), self.http_method_not_allowed - ) + method = request.method.lower() + if method in self.http_method_names: + handler = getattr(self, method, self.http_method_not_allowed) else: handler = self.http_method_not_allowed return handler(request, *args, **kwargs) |
