Passing reverse_lazy url to SpectacularRedocView errors.
I've chased down the issue to drf_spectacular.plumbing.set_query_parameters which uses urllib.parse.urlparse which needs a string to work.
To Reproduce
It would be most helpful to provide a small snippet to see how the bug was provoked.
-> scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url)
(Pdb) from django.urls import reverse_lazy
(Pdb) url = reverse_lazy('rest:v0:api-root') # Change the url name here to an actual url in the project
(Pdb) url
'/v0/'
(Pdb) type(url)
<class 'django.utils.functional.lazy.<locals>.__proxy__'>
(Pdb) urllib.parse.urlparse(str(url))
ParseResult(scheme='', netloc='', path='/v0/', params='', query='', fragment='')
(Pdb) urllib.parse.urlparse(url)
*** AttributeError: '__proxy__' object has no attribute 'decode'
(Pdb)
Expected behavior
If you change
scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url)
# to
scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(str(url))
# forcing the evaluation of the lazy url
Describe the bug
Passing reverse_lazy url to SpectacularRedocView errors.
I've chased down the issue to drf_spectacular.plumbing.set_query_parameters which uses urllib.parse.urlparse which needs a string to work.
To Reproduce It would be most helpful to provide a small snippet to see how the bug was provoked.
Expected behavior
If you change
it works as expected