Opened 5 years ago

Closed 5 years ago

#21216 closed Bug (fixed)

`OneToOneField` reverse accessor cannot be hidden.

Reported by: Simon Charette Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


ForeignKey allows to set a related_name ending with a '+' to hide the reverse accessor.

This can be quite useful when you want to reference a third-party app model but want to avoid polluting it when an unnecessary reverse descriptor.

Attaching a patch with tests and a release note. This should help #21212, which aims to document OneToOneField.related_name, to reuse/reference the existing ForeignKey one.

Attachments (1)

0001-Fixed-21216-Allow-OneToOneField-reverse-accessor-to-.patch (5.9 KB) - added by Simon Charette 5 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by Simon Charette

All tests pass on Python 2.7 with SQLite.

comment:2 Changed 5 years ago by Tim Graham

Triage Stage: UnreviewedReady for checkin

comment:3 Changed 5 years ago by Simon Charette <charette.s@…>

Resolution: fixed
Status: newclosed

In fa2e1371cda1e72d82b4133ad0b49a18e43ba411:

Fixed #21216 -- Allow OneToOneField reverse accessor to be hidden.

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