Opened 12 years ago
Closed 12 years ago
#20234 closed Bug (fixed)
SingleObjectMixin does not add 'object' key to context
Reported by: | Matthew Somerville | Owned by: | Karol Sikora |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | tinodb, marc.tamlyn@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:1 by , 12 years ago
Component: | Uncategorized → Generic views |
---|
comment:2 by , 12 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
Hmm, all "object" stuff does not seem to be very consistent (like you mention in your other tickets).
It also strikes me as strange, that these mixins rely on self.object
being set, while it is only set in it's derived classes (that is probably why object was passed as a kwarg earlier).
comment:3 by , 12 years ago
Cc: | added |
---|
I think the documented functionality is the correct functionality and this and #20236 can be fairly easily tidied up together.
comment:4 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
If this ticket is applied, then I think
get_context_data
ofModelFormMixin
becomes entirely superfluous - see ticket #20236.