diff options
| author | Natalia <124304+nessita@users.noreply.github.com> | 2025-03-20 11:32:54 -0300 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-03-24 11:53:42 -0300 |
| commit | 0b4f2d8d397dacb555b327435d1c815da59feda5 (patch) | |
| tree | d7132afaeee330003bd2b04363e34470e5272d60 /docs | |
| parent | b1c1fd33ed7a1192050b25bd0a256a97326d7692 (diff) | |
Fixed #36268 -- Added leading `?` in every querystring template tag result.
Thanks Sarah Boyce for the report.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 16 | ||||
| -rw-r--r-- | docs/releases/6.0.txt | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 5712b65d54..849faaa46f 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -967,9 +967,8 @@ Outputs a URL-encoded formatted query string based on the provided parameters. This tag requires a :class:`~django.http.QueryDict` instance, which defaults to :attr:`request.GET <django.http.HttpRequest.GET>` if none is provided. -If the :class:`~django.http.QueryDict` is empty and no additional parameters -are provided, an empty string is returned. Otherwise, the result includes a -leading ``"?"``. +The result always includes a leading ``"?"`` since this tag is mainly used for +links, and an empty result could prevent the page from reloading as expected. .. admonition:: Using ``request.GET`` as default @@ -979,6 +978,10 @@ leading ``"?"``. ``request`` object into the template context, or provide a ``QueryDict`` instance to this tag. +.. versionchanged:: 6.0 + + A ``?`` was prepended to the query string for empty results. + Basic usage ~~~~~~~~~~~ @@ -986,8 +989,9 @@ Basic usage {% querystring %} -Outputs the current query string verbatim. So if the query string is -``?color=green``, the output would be ``?color=green``. +Outputs the current query string verbatim. So if the query string in the +request is ``?color=green``, the output would be ``?color=green``. If the +current query string is empty, the output will be ``?``. .. code-block:: html+django @@ -1038,7 +1042,7 @@ Custom QueryDict You can provide a custom ``QueryDict`` to be used instead of ``request.GET``. So if ``my_query_dict`` is ``<QueryDict: {'color': ['blue']}>``, this outputs -``?color=blue``. +``?color=blue``. If ``my_query_dict`` is empty, the output will be ``?``. Dynamic usage ~~~~~~~~~~~~~ diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index f651274dfe..da69c73044 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -233,6 +233,9 @@ Templates * The new variable ``forloop.length`` is now available within a :ttag:`for` loop. +* The :ttag:`querystring` template tag now consistently prefixes the returned + query string with a ``?``, ensuring reliable link generation behavior. + Tests ~~~~~ |
