#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 , 9 years ago
comment:2 by , 9 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 9 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Version: | 1.9 → master |
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:6 by , 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:9 by , 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!
Pull request: https://github.com/django/django/pull/5890
All tests pass under SQLite.