MCPcopy Index your code
hub / github.com/encode/django-rest-framework / PKOnlyObject

Class PKOnlyObject

rest_framework/relations.py:68–79  ·  view source on GitHub ↗

This is a mock object, used for when we only need the pk of the object instance, but still want to return an object with a .pk attribute, in order to keep the same interface as a regular model instance.

Source from the content-addressed store, hash-verified

66
67
68class PKOnlyObject:
69 """
70 This is a mock object, used for when we only need the pk of the object
71 instance, but still want to return an object with a .pk attribute,
72 in order to keep the same interface as a regular model instance.
73 """
74
75 def __init__(self, pk):
76 self.pk = pk
77
78 def __str__(self):
79 return "%s" % self.pk
80
81
82# We assume that 'validators' are intended for the child serializer,

Calls

no outgoing calls