|Reported by:||akaariai||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
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 (5)
comment:1 Changed 4 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