Opened 4 years ago

Last modified 2 weeks ago

#34122 assigned Cleanup/optimization

Add reference docs for models.ForeignObject

Reported by: Ömer Faruk Abacı Owned by: somi
Component: Documentation Version: 4.1
Severity: Normal Keywords: custom join, multiple column join, foreignobject
Cc: Simon Charette, Mariusz Felisiak Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

While trying to implement a custom multiple-column join I have spent hours to find an elegant way, at the end I have found an old issue here:

https://code.djangoproject.com/ticket/19385

Then I have realized that I can use ForeignObject for custom joins. Almost all of the solutions online suggest using raw SQLs with Manager.raw() or QuerySet.extra(), none of them mention about ForeignObject. I don't know if it was on purpose or not but I thought that it might be good to mention about the ForeignObject in the following section:

https://docs.djangoproject.com/en/4.1/ref/models/relations/

What do you think?

Change History (16)

comment:1 by David Sanders, 4 years ago

Resolution: wontfix
Status: newclosed

ForeignObject isn't documented because it isn't earmarked for public use. That being said there's some external documentation on it in a few places to implement custom joins, one good one here: https://devblog.kogan.com/blog/custom-relationships-in-django

Closing as won'tfix. If you'd like to raise this topic making ForeignObject public please free to start a discussion on the DevelopersMailingList.

comment:2 by Ömer Faruk Abacı, 4 years ago

I see your point, thank you!

comment:3 by Carlton Gibson, 4 years ago

Cc: Simon Charette added

Simon had a proposal in his DjangoCon US 2020 keynote about documenting some of the internals in a way that would help people learn the ORM, but not make them public and so commit to API stability. I don't know how that would role out, or if this would fall under it specifically, but it seems related.

in reply to:  3 comment:4 by Mariusz Felisiak, 4 years ago

Replying to Carlton Gibson:

Simon had a proposal in his DjangoCon US 2020 keynote about documenting some of the internals in a way that would help people learn the ORM, but not make them public and so commit to API stability. I don't know how that would role out, or if this would fall under it specifically, but it seems related.

We have a ticket for this :), see #27617.

comment:5 by Carlton Gibson, 4 years ago

Of course we do :D

comment:6 by Sarah Boyce, 4 weeks ago

Cc: Mariusz Felisiak added
Resolution: wontfix
Status: closednew
Summary: models.ForeignObject is missing documentationAdd reference docs for models.ForeignObject

Note that since 978aae4334fa71ba78a3e94408f0f3aebde8d07c (#373) ForeignObject has been included in the docs related to CompositePrimaryKeys.
We have also followed a deprecation process in the past, see 8b1ff0da4b162e87edebd94e61f2cd153e9e159d. Reopening for us to reconsider adding reference documentation

See also discussion on the following PR: https://github.com/django/django/pull/21114

Last edited 4 weeks ago by Sarah Boyce (previous) (diff)

comment:7 by Sarah Boyce, 4 weeks ago

Triage Stage: UnreviewedAccepted

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 4 weeks ago

In 2c87f51:

Refs #373, #34122 -- Removed warning that ForeignObject is an internal tool.

ForeignObject should not be treated as an internal tool. In the past
we made changes in its API with a proper deprecation, e.g.
8b1ff0da4b162e87edebd94e61f2cd153e9e159d.

comment:9 by Sarah Boyce <42296566+sarahboyce@…>, 4 weeks ago

In 8ee7341:

[6.0.x] Refs #373, #34122 -- Removed warning that ForeignObject is an internal tool.

ForeignObject should not be treated as an internal tool. In the past
we made changes in its API with a proper deprecation, e.g.
8b1ff0da4b162e87edebd94e61f2cd153e9e159d.

Backport of 2c87f519f48038398c8d8a840fa5bf5497c353bb from main.

comment:10 by somi, 3 weeks ago

Owner: changed from nobody to somi
Status: newassigned

Picking this up. Plan to mirror the ForeignKey reference structure.
Thanks for reopening!

comment:11 by somi, 3 weeks ago

Has patch: set

comment:12 by Mariusz Felisiak, 3 weeks ago

Has patch: unset

comment:13 by somi, 3 weeks ago

Has patch: set

comment:15 by H. White, 2 weeks ago

Triage Stage: AcceptedReady for checkin

Reviewed, approved.

comment:16 by Mariusz Felisiak, 2 weeks ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted
Note: See TracTickets for help on using tickets.
Back to Top