You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ x] I have verified that that issue exists against the master branch of Django REST framework.
[x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
[ x] This is not a usage question. (Those should be directed to the discussion group instead.)
[x ] This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
[x ] I have reduced the issue to the simplest possible case.
[x ] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
Select 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>
Expected behavior
my-pretty-pk-uuid-string
Actual behavior
<rest_framework.relations.PKOnlyObject object at 0x7f9a6903d510>
Should 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>.
This simple monkey patch fixes the issue so I assume adding the method won't cause any problems
from rest_framework.relations import PKOnlyObject
PKOnlyObject.__str__ = lambda obj: str(obj.pk)
The text was updated successfully, but these errors were encountered:
Checklist
master
branch of Django REST framework.Steps to reproduce
Select 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>
Expected behavior
my-pretty-pk-uuid-string
Actual behavior
<rest_framework.relations.PKOnlyObject object at 0x7f9a6903d510>
Should 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>.
This simple monkey patch fixes the issue so I assume adding the method won't cause any problems
The text was updated successfully, but these errors were encountered: