Skip to content

Commit 0f75f8f

Browse files
authored
Optimized View.dispatch() a bit.
1 parent 315dbe6 commit 0f75f8f

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

django/views/generic/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ def dispatch(self, request, *args, **kwargs):
136136
# Try to dispatch to the right method; if a method doesn't exist,
137137
# defer to the error handler. Also defer to the error handler if the
138138
# request method isn't on the approved list.
139-
if request.method.lower() in self.http_method_names:
140-
handler = getattr(
141-
self, request.method.lower(), self.http_method_not_allowed
142-
)
139+
method = request.method.lower()
140+
if method in self.http_method_names:
141+
handler = getattr(self, method, self.http_method_not_allowed)
143142
else:
144143
handler = self.http_method_not_allowed
145144
return handler(request, *args, **kwargs)

0 commit comments

Comments
 (0)