Opened 8 years ago

Closed 8 years ago

#5989 closed (fixed)

django.db.models.fields.subclassing.Creator.__get__() returns the same value for all instances

Reported by: flupke Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: subclassing SubfieldBase custom field
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I added a test to modeltests/field_subclassing/ that illustrates the problem (in patch).

I also made a simple fix, storing to_python()-ised data in a per object dict.

Attachments (1)

subclassing.patch (1.3 KB) - added by flupke 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by flupke

comment:1 Changed 8 years ago by flupke

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Made a better version of the patch storing the to_python() value in the instance's dict, this way it gets destroyed with the instance without the need of a del method in Creator (thanks to Marty Alchin for explaining me that, see http://gulopine.gamemusic.org/2007/11/python-descriptors-part-2-of-2.html for details).

comment:2 Changed 8 years ago by flupke

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [6748]) Fixed #5989 -- Fixed a problem with values being incorrectly reused by
reference in field subclassing. Thanks, flupke.

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