{"action":"created","issue":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/4419","repository_url":"https://api.github.com/repos/tomchristie/django-rest-framework","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/4419/labels{/name}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/4419/comments","events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/4419/events","html_url":"https://github.com/tomchristie/django-rest-framework/issues/4419","id":172011368,"number":4419,"title":"PKOnlyObject doesn't have __str__/__unicode__ methods","user":{"login":"thenewguy","id":77731,"avatar_url":"https://avatars.githubusercontent.com/u/77731?v=3","gravatar_id":"","url":"https://api.github.com/users/thenewguy","html_url":"https://github.com/thenewguy","followers_url":"https://api.github.com/users/thenewguy/followers","following_url":"https://api.github.com/users/thenewguy/following{/other_user}","gists_url":"https://api.github.com/users/thenewguy/gists{/gist_id}","starred_url":"https://api.github.com/users/thenewguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thenewguy/subscriptions","organizations_url":"https://api.github.com/users/thenewguy/orgs","repos_url":"https://api.github.com/users/thenewguy/repos","events_url":"https://api.github.com/users/thenewguy/events{/privacy}","received_events_url":"https://api.github.com/users/thenewguy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-18T22:00:18Z","updated_at":"2016-08-19T12:26:49Z","closed_at":null,"body":"## Checklist\r\n\r\n- [ x] I have verified that that issue exists against the `master` branch of Django REST framework.\r\n- [x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.\r\n- [ x] This is not a usage question. (Those should be directed to the [discussion group](https://groups.google.com/forum/#!forum/django-rest-framework) instead.)\r\n- [x ] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](http://www.django-rest-framework.org/topics/third-party-resources/#about-third-party-packages) where possible.)\r\n- [x ] I have reduced the issue to the simplest possible case.\r\n- [x ] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)\r\n\r\n## Steps to reproduce\r\n\r\nSelect admin renderer. View a model that has a ForeignKey like `origin = models.ForeignKey(Address, related_name='+')`  See gibberish output like `<rest_framework.relations.PKOnlyObject object at 0x7f943b762950>`\r\n\r\n## Expected behavior\r\n\r\nmy-pretty-pk-uuid-string\r\n\r\n## Actual behavior\r\n\r\n`<rest_framework.relations.PKOnlyObject object at 0x7f9a6903d510>`\r\n\r\n\r\nShould be fairly simple to add __str__/__unicode__ methods so the link text is the pk value instead of something like `<rest_framework.relations.PKOnlyObject object at 0x7f9a6903d510>.`\r\n\r\n\r\n\r\nThis simple monkey patch fixes the issue so I assume adding the method won't cause any problems\r\n```\r\nfrom rest_framework.relations import PKOnlyObject\r\n\r\nPKOnlyObject.__str__ = lambda obj: str(obj.pk)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/comments/241004955","html_url":"https://github.com/tomchristie/django-rest-framework/issues/4419#issuecomment-241004955","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/4419","id":241004955,"user":{"login":"thenewguy","id":77731,"avatar_url":"https://avatars.githubusercontent.com/u/77731?v=3","gravatar_id":"","url":"https://api.github.com/users/thenewguy","html_url":"https://github.com/thenewguy","followers_url":"https://api.github.com/users/thenewguy/followers","following_url":"https://api.github.com/users/thenewguy/following{/other_user}","gists_url":"https://api.github.com/users/thenewguy/gists{/gist_id}","starred_url":"https://api.github.com/users/thenewguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thenewguy/subscriptions","organizations_url":"https://api.github.com/users/thenewguy/orgs","repos_url":"https://api.github.com/users/thenewguy/repos","events_url":"https://api.github.com/users/thenewguy/events{/privacy}","received_events_url":"https://api.github.com/users/thenewguy/received_events","type":"User","site_admin":false},"created_at":"2016-08-19T12:26:48Z","updated_at":"2016-08-19T12:26:48Z","body":"```\r\nPKOnlyObject.__str__ = lambda obj: str(obj.pk)\r\nPKOnlyObject.__unicode__ = lambda obj: text_type(obj.pk)\r\n```\r\n\r\nno monkeypatch:\r\n\r\n<img width=\"959\" alt=\"drf-issue-4419-no-monkeypatch\" src=\"https://cloud.githubusercontent.com/assets/77731/17809717/989067d6-65e6-11e6-91b7-0b56a2c38db6.png\">\r\n\r\n\r\nhas monkeypatch:\r\n\r\n<img width=\"960\" alt=\"drf-issue-4419-has-monkeypatch\" src=\"https://cloud.githubusercontent.com/assets/77731/17809731/a4bcd74c-65e6-11e6-803c-03b5f63b976e.png\">\r\n"}}
{"actor":{"display_login":"thenewguy"}}