def view(request, *args, **kwargs): """Slightly modified Django wrapped view. @see django.views.generic.base.View """ self = get_cls(cls, kwargs, initkwargs) if hasattr(self, 'get') and not hasattr(self, 'head'): self.head = self.get self.request = request self.args = args self.kwargs = kwargs return self.dispatch(request, *args, **kwargs)
def view(request, *args, **kwargs): """Slightly modified rest_framework wrapped view. @see rest_framework.viewsets.ViewSetMixin """ self = get_cls(cls, kwargs, initkwargs) # 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. self.action_map = actions # Bind methods to actions # This is the bit that's different to a standard view for method, action in actions.items(): handler = getattr(self, action) setattr(self, method, handler) # Patch this in as it's otherwise only present from 1.5 onwards if hasattr(self, 'get') and not hasattr(self, 'head'): self.head = self.get # And continue as usual return self.dispatch(request, *args, **kwargs)