I have a viewset with a retrieve view, which takes one parameter, which is a string url encoded, as it often has '/' in it. Now when I send a request to my local development server with the url encoded (every / replaced by %2F) I get a 404 from my server and in the "Request URL" I see my string but decoded - so it makes sense that there is no such route. The route shows up correctly in this debug view with api/ ^topic/(?P<pk>[^/.]+)/$. This is my viewset:
class TopicAPI(viewsets.ViewSet):
def retrieve(self, request, pk=None):
if '%2F' in pk:
pk = pk.replace('%2F', '/')
# Data retrival which works (independently tested)
return Response(topics)
I tried different words and different replacement methods, i.e. '--' instead of '2%F' which works but isn't nearly as stable as url encoding.