diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-07-23 05:04:06 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-25 08:15:20 +0200 |
| commit | 5ed20b3aa3536539b9bc1cb5b40e84e3147a2228 (patch) | |
| tree | 559c955e75e0e30c992eb5836b9eb9aea4b8fed8 /docs | |
| parent | 93ffa81bc59ff13c1a5c07f5bd22d003756e1da5 (diff) | |
Fixed #30657 -- Allowed customizing Field's descriptors with a descriptor_class attribute.
Allows model fields to override the descriptor class used on the model
instance attribute.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/fields.txt | 10 | ||||
| -rw-r--r-- | docs/releases/3.0.txt | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 758c21c7bc..ead39f0572 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1793,6 +1793,16 @@ Field API reference where the arguments are interpolated from the field's ``__dict__``. + .. attribute:: descriptor_class + + .. versionadded:: 3.0 + + A class implementing the :py:ref:`descriptor protocol <descriptors>` + that is instantiated and assigned to the model instance attribute. The + constructor must accept a single argument, the ``Field`` instance. + Overriding this class attribute allows for customizing the get and set + behavior. + To map a ``Field`` to a database-specific type, Django exposes several methods: diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt index 34152573f0..07a2396c80 100644 --- a/docs/releases/3.0.txt +++ b/docs/releases/3.0.txt @@ -283,6 +283,10 @@ Models :class:`~django.db.models.Index` now support app label and class interpolation using the ``'%(app_label)s'`` and ``'%(class)s'`` placeholders. +* The new :attr:`.Field.descriptor_class` attribute allows model fields to + customize the get and set behavior by overriding their + :py:ref:`descriptors <descriptors>`. + Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ |
