While fixing #27897, which is caused by calling `.get_field('pk')`, I ran
across the fact that we are now checking `== 'pk'` before calling
`.get_field` in several places. My proposal is to simply handle this
special case inside of `get_field` directly.
I have a patch but there is a single test regression on
[https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L232-L239|
this system check]. My idea was to change the message and `obj` to
`self.model` but I'm not sure what the backwards compatibility guarantees
are for the message.
Regardless I think we should do this because it will prevent a whole class
of bugs in the future and `'pk'` is already special cased everywhere.
--
Ticket URL: <https://code.djangoproject.com/ticket/27944>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* component: Uncategorized => Database layer (models, ORM)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:1>
* owner: nobody => Josh Schneier
* status: new => assigned
* has_patch: 0 => 1
Comment:
Patch here: https://github.com/django/django/pull/8191
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:2>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:3>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:4>
* stage: Accepted => Someday/Maybe
Comment:
The discussion on the PR suggests that a DevelopersMailingList discussion
is needed to see if there's consensus to proceed with this.
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:5>
* status: assigned => closed
* resolution: => wontfix
Comment:
I think this can be closed as ''wontfix'' given the discussion on the
mailing list didn't reach consensus around the backward compatibility
risks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27944#comment:6>