#26807: Document how to replicate SubfieldBase behavior of calling to_python on
assignment
--------------------------------------+------------------------------------
Reporter: akx | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):
* needs_better_patch: => 0
* component: Database layer (models, ORM) => Documentation
* needs_tests: => 0
* version: 1.9 => 1.8
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
The [https://groups.google.com/d/topic/django-
developers/0nauqFFwscU/discussion django-developers thread] that proposed
the removal of `SubfieldBase` says:
Django provides a metaclass called `SubfieldBase`, which basically means
that that field will have it's `to_python()` method called whenever a
value is assigned to the model, including when it is loaded from the
database. This really is an abuse of `to_python()` whose primary purpose
is to convert strings from serialisation and forms into the relevant
python object.
The deprecation note in the the 1.8 release notes says, "the new approach
does not call the `to_python()` method on assignment as was the case with
`SubfieldBase`." We could say that custom fields can copy the `Creator`
implementation if they require this behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/26807#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.cf4c188e3431d8885c25226b2b5a9f04%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.