|Reported by:||Anssi Kääriäinen||Owned by:||Tim Graham|
|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 (12)
comment:1 Changed 3 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Unreviewed → Accepted|
|Version:||1.6 → master|