1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Optimized View.dispatch() a bit.

This commit is contained in:
sobolevn
2025-10-12 23:09:46 +03:00
committed by GitHub
parent 315dbe675d
commit 0f75f8f1ff

View File

@@ -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)