Simplified HEAD handling for method views

This commit is contained in:
Armin Ronacher 2011-09-17 19:39:10 +02:00
parent 7d7d810aea
commit 32c7e43dda
3 changed files with 42 additions and 1 deletions

View file

@ -143,5 +143,9 @@ class MethodView(View):
def dispatch_request(self, *args, **kwargs):
meth = getattr(self, request.method.lower(), None)
assert meth is not None, 'Not implemented method'
# if the request method is HEAD and we don't have a handler for it
# retry with GET
if meth is None and request.method == 'HEAD':
meth = getattr(self, 'get', None)
assert meth is not None, 'Not implemented method %r' % request.method
return meth(*args, **kwargs)