[Django] #33821: Use _fk as suffix for augmented related model value fields

8 views
Skip to first unread message

Django

unread,
Jul 4, 2022, 5:55:02 AM7/4/22
to django-...@googlegroups.com
#33821: Use _fk as suffix for augmented related model value fields
-------------------------------------+-------------------------------------
Reporter: Anton | Owner: nobody
Agestam |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 4.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django uses _id as suffix [1] for accessing the underlying related value
for relationship fields (ForeignKey et al). This is cause for a lot of
confusion when used in conjunction with `to_field`, that is when having a
relation to a non-primary key field. It's also confusing if the primary
key field of the related model isn't named `id`.

[1]: https://docs.djangoproject.com/en/4.0/ref/models/fields/#database-
representation

To make this situation better, I propose replacing the _id suffix with _fk
instead, which makes it more obvious that this value is a sort of proxy to
a value on the related model. Of course this change couldn't be made
without a proper deprecation cycle, so the _id suffix should work in
parallel with the new _fk field for a sufficient length of time to be
phased out.

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

Django

unread,
Jul 4, 2022, 7:29:58 AM7/4/22
to django-...@googlegroups.com
#33821: Use _fk as suffix for augmented related model value fields
-------------------------------------+-------------------------------------
Reporter: Anton Agestam | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: new => closed
* resolution: => wontfix


Comment:

Thanks for this suggestion, however the proposed change is highly backward
incompatible and cannot be moved forward without a strong consensus on the
DevelopersMailingList. Please first start a discussion on the
DevelopersMailingList, where you'll reach a wider audience and see what
other think, and
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features follow the guidelines with regards to
requesting features]. Personally, I don't think it's worth changing.

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

Reply all
Reply to author
Forward
0 new messages