[Django]-How to get value to one html page to another in Django?

3👍

Sending entire local variables to the template may be dangerous and insecure, as well as unnecessary so instead of passing locals(), you can either pass the entire querystring using request.GET or just the value keyed with search_box:

return render(request, "interface/recherche.html", request.GET)

or

return render(request, "interface/recherche.html", {"search_box": search_query})

and you can print out the value in recherche.html like {{ search_box }}.

You can test it out by typing something like /page2?search_box=text into the address bar of your browser. The page should display text.

Leave a comment