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 , 4 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
follow-up: 4 comment:3 by , 4 years ago
| Cc: | 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.
comment:4 by , 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:6 by , 4 weeks ago
| Cc: | added |
|---|---|
| Resolution: | wontfix |
| Status: | closed → new |
| Summary: | models.ForeignObject is missing documentation → Add 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
comment:7 by , 4 weeks ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:10 by , 3 weeks ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
Picking this up. Plan to mirror the ForeignKey reference structure.
Thanks for reopening!
comment:11 by , 3 weeks ago
| Has patch: | set |
|---|
comment:12 by , 3 weeks ago
| Has patch: | unset |
|---|
comment:13 by , 3 weeks ago
| Has patch: | set |
|---|
comment:16 by , 2 weeks ago
| Patch needs improvement: | set |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
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.