Skip to content

Commit

Permalink
Force evaluation of reverse_lazy urls in set_query_parameters. Fixes #…
Browse files Browse the repository at this point in the history
…1311

Passing reverse_lazy url to SpectacularRedocView errors because set_query_parameters calls urlls.parse.urlparse on url which may not be a string but a 'django.utils.functional.lazy.<locals>.__proxy__'. Forcing url to be string fixes this issue.
  • Loading branch information
isik-kaplan authored Oct 12, 2024
1 parent 0dea78c commit 74e12f8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drf_spectacular/plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ def build_mock_request(method, path, view, original_request, **kwargs):

def set_query_parameters(url, **kwargs) -> str:
""" deconstruct url, safely attach query parameters in kwargs, and serialize again """
url = str(url) # Force evaluation of reverse_lazy urls
scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url)
query = urllib.parse.parse_qs(query)
query.update({k: v for k, v in kwargs.items() if v is not None})
Expand Down

0 comments on commit 74e12f8

Please sign in to comment.