ProcessFormView should pass **kwargs to get_context_data()
|Reported by:||cjerdonek||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the ProcessFormView class, keyword arguments to the view aren't available in the template context by default.
From what I can tell, changing this behavior (so that one can customize other aspects of the template) requires relying on undocumented implementation details of Django views (namely that View.as_view() sets self.kwargs). For example:
def get_context_data(self, **kwargs): # ProcessFormView doesn't pass the view's keyword arguments in its # calls to get_context_data(), so we need to add them back manually. context = self.kwargs.copy() context.update(kwargs) return context
I think things would be simpler and more consistent if ProcessFormView passed the view's **kwargs to get_context_data() in the first place, in which case ProcessFormView could implement its own version of get_context_data() that would restrict the context. This would be more DRY by eliminating the need to read self.kwargs when overriding get_context_data(). This will also reduce potential confusion between the **kwargs argument and the undocumented self.kwargs attribute.
Change History (5)
comment:1 Changed 19 months ago by cjerdonek
- Cc chris.jerdonek@… added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset