Fix for null HyperlinkedRelatedField in POST/PUT

This commit is contained in:
James Oakley 2012-11-21 16:48:39 -08:00
parent afa75db65d
commit b95f505c74

View File

@ -574,6 +574,9 @@ class HyperlinkedRelatedField(RelatedField):
if self.queryset is None: if self.queryset is None:
raise Exception('Writable related fields must include a `queryset` argument') raise Exception('Writable related fields must include a `queryset` argument')
if value is None:
return None
if value.startswith('http:') or value.startswith('https:'): if value.startswith('http:') or value.startswith('https:'):
# If needed convert absolute URLs to relative path # If needed convert absolute URLs to relative path
value = urlparse(value).path value = urlparse(value).path