Changes between Version 2 and Version 3 of Ticket #31701
- Timestamp:
- Jun 13, 2020, 12:19:25 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31701
- Property Summary Extend DeferredAttribute & Remove unnecessary overriding of contrib_to_class () in FileField → Extend DeferredAttribute & Remove unnecessary FileField.contrib_to_class ()
-
Ticket #31701 – Description
v2 v3 3 3 To access the field data in instance dict, **Field.attname** is used as a key. 4 4 5 In addition to the field data, some other model fields (for example, ForeignKey) also use a "client data" of the attribute, the processing of which is performed by a particular descriptor. Such a descriptor is usually assigned to a model using **Field.name**. 5 In addition to the field data, some other model fields (for example, ForeignKey) also use a "client data" of the attribute, the processing of which is performed by a particular descriptor. Such a descriptor is usually assigned to a model using **Field.name**. Its task is to present the same field data in a different format, the result of which differs from the result of Field.attname descriptor: `article.author` returns a User object, and `article.auther_id` returns a User object pk. 6 This feature is not used in FileField. Then why use FileField.name instead of FileField.attname for FileDescriptor? 6 7 7 This enables us to process and present the data in different ways: article.author returns a User object, and article.auther_id returns a User object pk. 8 9 This feature is not used in model.FileField. Then why use FileField.name instead of FileField.attname for FileDescriptor? 10 11 I think it would be better if FileDescriptor uses field.attname and continue working with the DeferredAttribute class. 8 I think it would be better if FileDescriptor uses FileField.attname and continue working with the DeferredAttribute class.