Hyperlink Class Cannot Be Pickled · Issue #3628 · encode/django-rest-framework (original) (raw)

@mlavin

Related to #3350, the rest_framework.relations.Hyperlink instances cannot be pickled as demonstrated with this sample:

>>> import pickle
>>> from rest_framework.relations import Hyperlink
>>> link = Hyperlink('http://example.com', 'test')
>>> pickle.loads(pickle.dumps(link))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: __new__() missing 1 required positional argument: 'name'

For serializers which use the hyperlink relations, this breaks the caching of the response objects since most of the cache backends rely on pickle by default.