diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 40261f3f3e..744823c486 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -32,6 +32,9 @@ def __new__(self, url, name): ret.name = name return ret + def __getnewargs__(self): + return(str(self), self.name,) + is_hyperlink = True diff --git a/tests/test_relations.py b/tests/test_relations.py index fd37e63e31..9469cd0682 100644 --- a/tests/test_relations.py +++ b/tests/test_relations.py @@ -206,3 +206,14 @@ def test_get_value_multi_dictionary_partial(self): mvd = MultiValueDict({'baz': ['bar1', 'bar2']}) assert empty == self.field.get_value(mvd) + + +class TestHyperlink: + def setup(self): + self.default_hyperlink = serializers.Hyperlink('http://example.com', 'test') + + def test_can_be_pickled(self): + import pickle + upkled = pickle.loads(pickle.dumps(self.default_hyperlink)) + assert upkled == self.default_hyperlink + assert upkled.name == self.default_hyperlink.name pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy