Opened 16 years ago

Closed 16 years ago

#5989 closed (fixed)

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

Reported by: Luper Rouch Owned by: nobody
Component: Database layer (models, ORM) Version: dev
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: no UI/UX: no

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 Luper Rouch 16 years ago.

Download all attachments as: .zip

Change History (4)

by Luper Rouch, 16 years ago

Attachment: subclassing.patch added

comment:1 by Luper Rouch, 16 years ago

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 by Luper Rouch, 16 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(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