Opened 5 years ago

Closed 5 years ago

#30657 closed New feature (fixed)

Allow model Fields to override their descriptor.

Reported by: Jon Dufresne Owned by: Jon Dufresne
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Right now, a Field is assigned to the model instance attribute using the DeferredAttribute descriptor class.

https://github.com/django/django/blob/d89053585e11e869efcc9debb1c311b47b5e20ea/django/db/models/fields/__init__.py#L741

As discussed in PR#11587, it would be useful to third party libraries and internally if this descriptor class could be customized to allow for custom behavior.

Change History (4)

comment:1 by Jon Dufresne, 5 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 5 years ago

Owner: changed from nobody to Jon Dufresne
Status: newassigned
Summary: Allow model Fields to override their descriptorAllow model Fields to override their descriptor.
Triage Stage: UnreviewedAccepted

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 93ffa81b:

Refs #30657 -- Made DeferredAttribute.init() to take a field instance instead of a field name.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 5ed20b3a:

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.

Note: See TracTickets for help on using tickets.
Back to Top