It seems to me that in Django's generic class-based views, the parameters request
, args
and kwargs
travel from method to method, both as view instance attributes, as well as method arguments.
What do I mean exactly?
Class django.views.generic.base.View
, defines the following function, called by its as_view
method:
def view(request, *args, **kwargs):
self = cls(**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)
This function first sets request
, args
and kwargs
as view instance attributes, and then invokes the view's dispatch
method with all these as arguments. What exactly is the purpose of this, if any? Isn't it redundant?