I have link looking like that:
<a href="{% url 'home-paginated' page_obj.next_page_number %}">Next</a>
and function getting params from current link:
function GetParams(){
const queryString = window.location.search;
console.log(queryString);
return queryString
}
and I'd like to set href value to connection of {% url 'home-paginated' page_obj.next_page_number %} and value returned by GetParams function (or just window.location.search)
for example let current link be
http://127.0.0.1:8000/2?sorted=normal
and after clicking "a" tag link should look like:
http://127.0.0.1:8000/3?sorted=normal
CodePudding user response:
You can encode the querystring again with {{ request.GET.urlencode }}
:
<a href="{% url 'home-paginated' page_obj.next_page_number %}?{{ request.GET.urlencode }}">Next</a>