Clarify View.as_view() docs in respect to functions passed as kwargs.
|Reported by:||gg||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 russellm
- Component changed from Generic views to Documentation
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 5 years ago by lrekucki
- Severity set to Normal
- Summary changed from Functions passed as kwargs to View.as_view() should be bound to Clarify View.as_view() docs in respect to functions passed as kwargs.
- Type set to Cleanup/optimization