Use serializers.HyperlinkedRelatedField where defined lookup_field link to the field string causes an exception 'Invalid hyperlink - Object does not exist.' when the value of that field contains characters that are encoded in the url. eg space -> %20
Missing unquote when try get the value from the url
The text was updated successfully, but these errors were encountered:
The view with custom lookup field doesn't seem to cause any trouble by itself.
So why does resolve it work in view, but not in related field? '%20' in path gets unquoted quite early on, already in WSGI server (or django test client). This is seems not exactly well defined part of WSGI, so some servers may not unquote this, but django builtin server does, and so is uwsgi and few others. Anyway, this is just explanation why it does seem to work when working with path from taken request object.
In related field we deal with user provided data, which is not parsed by any magical WSGI implementation. So I think we should call uri_to_iri (just like django test server) on urlparse.urlparse(data).path.