Clarify View.as_view() docs in respect to functions passed as kwargs.
|Reported by:||Gabriel Grant||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
At the moment, generic.base.View.as_view() passes kwargs to the class' init (which
setattrs them), rather than dynamically subclassing. The introductory generic view docs, however, seem to imply that passing kwargs to the as_view() method is equivalent to overriding the class. For example, it refers to "pass[ing] the new attributes into the as_view method call" as an "overriding pattern." This makes it rather surprising that functions passed to as_view() aren't bound to the resultant instance.
It seems to me that as_view() should dynamically create a subclass with the provided kwargs. Alternatively, if that is deemed undesirable, the docs should at least be clarified to better explain the true behaviour.
I can provide a patch, but need someone (*cough* RKM :) to confirm the desired behaviour.
Change History (8)
comment:1 Changed 6 years ago by
|Component:||Generic views → Documentation|
|Triage Stage:||Unreviewed → Accepted|
comment:2 Changed 6 years ago by
|Summary:||Functions passed as kwargs to View.as_view() should be bound → Clarify View.as_view() docs in respect to functions passed as kwargs.|