Kwargs are not in the context if you inherit from BaseListView or it's subclasses
|Reported by:||Fact Fiber||Owned by:||nobody|
|Severity:||Normal||Keywords:||generic views list baselistview kwargs|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The problem occurs when you inherit from BaseListView (or a view that inherits from it) and you assume that context contains kwargs. This is a fair assumption as MultipleObjectMixin.get_context_data() contains:
Kwargs should be passed to self.get_context_data() in BaseListView and they're not. Therefore the mentioned line of code code in MultipleObjectMixin doesn't have any effect.
This looks like a bug as MultipleObjectMixin.get_context_data() which is exactly the one called in BaseListView uses kwargs to update the context, but the kwargs are not passed so this breaks the chain.
Steps to reproduce:
- Inherit from BaseListView (or its subclasses, e.g. ListView).
- Update kwargs in your view
- Kwargs should be available in the context
BaseListView's get() should pass kwargs to get_context_data()
The proposed patch is attached
Change History (4)
Changed 3 years ago by Fact Fiber
comment:1 Changed 3 years ago by ptone
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted