python - Django set GET parameter based on selection -
in html template, under localhost:8000/
, have hrefs
:
en en-us gb fr
when users clicks fr
want make url localhost:8000/country=fr
how that? thanks
views.py:
langs = language.objects.all() return render(request, 'themes_list.html', {'langs': langs})
template:
<h2>select language:</h2> {% lang in langs %} <a href=".......">{{ lang.code }}</a> {% endfor %}
when users clicks fr, can make url
localhost:8000/?country=fr
by writing html like
<a href="/?country={{lang.code}}">{{ lang.code }}</a>
the url without question not possible
localhost:8000/country=fr
Comments
Post a Comment