SingleObjectMixin does not add 'object' key to context
|Reported by:||Matthew Somerville||Owned by:||Karol Sikora|
|Cc:||tinodb, marc.tamlyn@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The documentation at https://docs.djangoproject.com/en/dev/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin says that 'object' will be in the context, as well as potentially context_object_name if given. However, actually only context_object_name is set in the context by this mixin; only if object is passed to the mixin (which BaseDetailView does) will it be included.
The MultipleObjectMixin does include 'object_list' in its get_context_data (though assumes it must be passed in rather than on the object, I'll file that as another ticket), so I assume this is an issue with SingleObjectMixin, and that it should set 'object' on context whether it is passed in as a kwarg or not.
I have a patch on a branch of my github fork: https://github.com/dracos/django/compare/singleobjectfixin
Change History (6)
comment:2 Changed 4 years ago by
|Triage Stage:||Unreviewed → Accepted|
|Type:||Uncategorized → Bug|
comment:4 Changed 4 years ago by
|Owner:||changed from nobody to Markus Holtermann|
|Status:||new → assigned|