|Reported by:||akaariai||Owned by:||timgraham|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently related fields have two similar attributes, self.rel and self.related. The first is ForeignObjectRel subclass, the second is RelatedObject. Both of these do almost the same thing, and it doesn't seem necessary to have both rel and related. It is confusing to try to remember which one does what.
In the proposed patch at https://github.com/akaariai/django/tree/related_rel_removal the RelatedObject usage is removed. The idea is to make ForeignObjectRel to work exactly like RelatedObject worked and provide the same instance from field.rel and field.related.
I've opted for deprecation path where RelatedObject can still be used, and so can field.related, too. The field.related attribute is actually ForeignObjectRel, but by usage of __instancecheck__ isinstance(field.related, RelatedObject) answers yes. This should make this change easy for 3rd party apps.
Change History (11)
comment:1 Changed 18 months ago by loic84
- Cc loic@… added
- Has patch set
- Needs documentation set
- Needs tests unset
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Accepted
- Version changed from 1.6 to master
comment:7 Changed 4 months ago by timgraham
- Owner changed from nobody to timgraham
- Status changed from new to assigned
comment:9 Changed 4 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from assigned to closed