#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070181c8a273d2-1c13c05e-af91-484a-a888-2c2b44c96e54-000000%40eu-central-1.amazonses.com.