mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-25 19:43:47 +03:00
Add __str__ method to PKOnlyObject (#4423)
This commit is contained in:
parent
63342e81db
commit
a335309b33
|
@ -10,7 +10,7 @@ from django.core.urlresolvers import (
|
||||||
from django.db.models import Manager
|
from django.db.models import Manager
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.encoding import smart_text
|
from django.utils.encoding import python_2_unicode_compatible, smart_text
|
||||||
from django.utils.six.moves.urllib import parse as urlparse
|
from django.utils.six.moves.urllib import parse as urlparse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class Hyperlink(six.text_type):
|
||||||
is_hyperlink = True
|
is_hyperlink = True
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class PKOnlyObject(object):
|
class PKOnlyObject(object):
|
||||||
"""
|
"""
|
||||||
This is a mock object, used for when we only need the pk of the object
|
This is a mock object, used for when we only need the pk of the object
|
||||||
|
@ -56,6 +57,9 @@ class PKOnlyObject(object):
|
||||||
def __init__(self, pk):
|
def __init__(self, pk):
|
||||||
self.pk = pk
|
self.pk = pk
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s" % self.pk
|
||||||
|
|
||||||
|
|
||||||
# We assume that 'validators' are intended for the child serializer,
|
# We assume that 'validators' are intended for the child serializer,
|
||||||
# rather than the parent serializer.
|
# rather than the parent serializer.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user