Opened 2 years ago

Closed 2 years ago

#33821 closed Cleanup/optimization (wontfix)

Use _fk as suffix for augmented related model value fields

Reported by: Anton Agestam Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (1)

comment:1 by Mariusz Felisiak, 2 years ago

Resolution: wontfix
Status: newclosed

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 follow the guidelines with regards to requesting features. Personally, I don't think it's worth changing.

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