id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 27944 Have meta.get_field('pk') return the primary key field directly Josh Schneier Josh Schneier "Follow up ticket discussion on this topic: https://github.com/django/django/pull/8148 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. " Cleanup/optimization closed Database layer (models, ORM) dev Normal wontfix Someday/Maybe 1 0 0 0 0 0