[Django] #31591: Spanning relationship backwards when related_name is used.

8 views
Skip to first unread message

Django

unread,
May 15, 2020, 7:00:26 AM5/15/20
to django-...@googlegroups.com
#31591: Spanning relationship backwards when related_name is used.
-------------------------------------+-------------------------------------
Reporter: Nat S | Owner: nobody
Dunn |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 3.0
Documentation |
Severity: Normal | Keywords: related_name
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Under https://docs.djangoproject.com/en/3.0/topics/db/queries/#lookups-
that-span-relationships, the documentation says:

It works backwards, too. To refer to a “reverse” relationship, **use the
lowercase name of the model**.

This works only if the name of that relationship hasn't been changed with
**related_name**.

I suggest updating the doc to read:

It works backwards, too. To refer to a “reverse” relationship, use the
lowercase name of the model**, unless you have used related_name to
override the name of the relationship, in which case you should use the
related_name you have set.**

--
Ticket URL: <https://code.djangoproject.com/ticket/31591>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 19, 2020, 4:57:00 AM5/19/20
to django-...@googlegroups.com
#31591: Spanning relationship backwards when related_name is used.
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Carlton
Type: | Gibson
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: related_name | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: nobody => Carlton Gibson
* status: new => assigned
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

OK, yes. Good spot.

The docs should probably cross-reference
https://docs.djangoproject.com/en/3.0/topics/db/queries/#following-
relationships-backward here.

At the least it's lowercased + `_set`, so correcting the examples to match
the sample models at the top would probably also ease confusion.

[https://github.com/django/django/pull/12935 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31591#comment:1>

Django

unread,
May 19, 2020, 2:27:17 PM5/19/20
to django-...@googlegroups.com
#31591: Spanning relationship backwards when related_name is used.
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Carlton
Type: | Gibson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.0
Severity: Normal | Resolution: fixed

Keywords: related_name | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5af17babb0f895cf129fdeee92548d2ac12e78e2" 5af17ba]:
{{{
#!CommitTicketReference repository=""
revision="5af17babb0f895cf129fdeee92548d2ac12e78e2"
Fixed #31591 -- Clarified "reverse" lookup name in making queries docs.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31591#comment:2>

Django

unread,
May 19, 2020, 2:27:57 PM5/19/20
to django-...@googlegroups.com
#31591: Spanning relationship backwards when related_name is used.
-------------------------------------+-------------------------------------
Reporter: Nat S Dunn | Owner: Carlton
Type: | Gibson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.0
Severity: Normal | Resolution: fixed
Keywords: related_name | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"844e0591f9591854a0411fb8d90282737f17c40c" 844e0591]:
{{{
#!CommitTicketReference repository=""
revision="844e0591f9591854a0411fb8d90282737f17c40c"
[3.1.x] Fixed #31591 -- Clarified "reverse" lookup name in making queries
docs.

Backport of 5af17babb0f895cf129fdeee92548d2ac12e78e2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31591#comment:3>

Reply all
Reply to author
Forward
0 new messages