Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26006 closed Cleanup/optimization (fixed)

SingleObjectMixin.get_context_object_name refers to obj and self.object inconsistently

Reported by: Chris Cogdon Owned by: Chris Cogdon
Component: Generic views Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The method SingleObjectMixin.get_context_object_name refers to the 'obj' parameter several times, but in one instance refers to self.object in a seemingly inconsistent manner.

This is probably not causing a problem, yet, since the descendant class, typically BaseDetailView, is setting self.object, and SingleObjectMixin.get_context_data simply calls self.get_context_object_name(self.object), so the two are _usually_ the same object.

Trivial bug, and trivial fix. I'll create a pull request. Test suite passes both before and after the change.

Change History (9)

comment:1 by Chris Cogdon, 9 years ago

Pull request: https://github.com/django/django/pull/5890

All tests pass under SQLite.

comment:2 by Chris Cogdon, 9 years ago

Has patch: set
Owner: changed from nobody to Chris Cogdon
Status: newassigned

comment:3 by Chris Cogdon, 9 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Simon Charette, 9 years ago

Needs tests: set
Patch needs improvement: set
Version: 1.9master

The change makes sense.

This should be good to go once you add a regression test or adjust the ones added by this check.

comment:5 by Chris Cogdon, 9 years ago

Thank you for the link to the changes. I'll set up a test case.

comment:6 by Chris Cogdon, 9 years ago

Needs tests: unset
Patch needs improvement: unset

Pull request updated: https://github.com/django/django/pull/5890

Unit test added. Release notes updated. Still passes all tests. Documentation compiles without error.

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 4b2dcfe:

Fixed #26006 -- Fixed incorrect object reference in SingleObjectMixin.get_context_object_name().

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 4d9b986:

[1.9.x] Fixed #26006 -- Fixed incorrect object reference in SingleObjectMixin.get_context_object_name().

Backport of 4b2dcfe04f5d9938e40c569ffdd169f3a712145d from master

comment:9 by Chris Cogdon, 9 years ago

My first commit! I am so proud! 😺

Also, I see you caught the extraneous dot in the release notes. Almost nothing gets by you!

Note: See TracTickets for help on using tickets.
Back to Top