Skip to content

Commit

Permalink
Merge pull request #3701 from Cheglader/master
Browse files Browse the repository at this point in the history
Fix #3628 by implementing __getnewargs__()
  • Loading branch information
xordoquy committed Dec 7, 2015
2 parents b8d109f + 4b59681 commit 6bbb289
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rest_framework/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
11 changes: 11 additions & 0 deletions tests/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6bbb289

Please sign in to comment.