summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJake Howard <RealOrangeOne@users.noreply.github.com>2024-05-29 14:48:27 +0100
committerGitHub <noreply@github.com>2024-05-29 10:48:27 -0300
commitff308a06047cd60806d604a7cf612e5656ee2ac9 (patch)
treef2139fbf020cbdf33bad64a3377700623c18a44f /docs
parent02dab94c7b8585c7ae3854465574d768e1df75d3 (diff)
Fixed 35467 -- Replaced urlparse with urlsplit where appropriate.
This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used).
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/urlresolvers.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/ref/urlresolvers.txt b/docs/ref/urlresolvers.txt
index eb0b991f1b..b335d1fc39 100644
--- a/docs/ref/urlresolvers.txt
+++ b/docs/ref/urlresolvers.txt
@@ -203,7 +203,7 @@ A :class:`ResolverMatch` object can also be assigned to a triple::
One possible use of :func:`~django.urls.resolve` would be to test whether a
view would raise a ``Http404`` error before redirecting to it::
- from urllib.parse import urlparse
+ from urllib.parse import urlsplit
from django.urls import resolve
from django.http import Http404, HttpResponseRedirect
@@ -215,7 +215,7 @@ view would raise a ``Http404`` error before redirecting to it::
# modify the request and response as required, e.g. change locale
# and set corresponding locale cookie
- view, args, kwargs = resolve(urlparse(next)[2])
+ view, args, kwargs = resolve(urlsplit(next).path)
kwargs["request"] = request
try:
view(*args, **kwargs)