Opened 11 years ago

Closed 11 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: 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: no UI/UX: no


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 11 years ago.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by Luper Rouch

Attachment: subclassing.patch added

comment:1 Changed 11 years ago by Luper Rouch

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 for details).

comment:2 Changed 11 years ago by Luper Rouch

Triage Stage: UnreviewedReady for checkin

comment:3 Changed 11 years ago by Malcolm Tredinnick

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