From 5ed20b3aa3536539b9bc1cb5b40e84e3147a2228 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 23 Jul 2019 05:04:06 -0700 Subject: 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. --- docs/ref/models/fields.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs/ref/models') 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 ` + 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: -- cgit v1.3