Add 'head' to viewset actions map

This commit is contained in:
Ryan P Kilby 2020-03-07 18:19:14 -08:00
parent 87f5b42db7
commit b58b344edc

View File

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