diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 244c14d39..cad032dd9 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -93,6 +93,10 @@ class ViewSetMixin: def view(request, *args, **kwargs): self = cls(**initkwargs) + + if 'get' in actions and 'head' not in actions: + actions['head'] = actions['get'] + # We also store the mapping of request methods to actions, # so that we can later set the action attribute. # eg. `self.action = 'list'` on an incoming GET request. @@ -104,9 +108,6 @@ class ViewSetMixin: handler = getattr(self, action) setattr(self, method, handler) - if hasattr(self, 'get') and not hasattr(self, 'head'): - self.head = self.get - self.request = request self.args = args self.kwargs = kwargs