I'm currently working on a language switcher form for my website which supports 3 languages. Everything is functional except that when the page reloads, the content changes to the new language but the selected option from the dropdown reverts back to the default language. I'm looking for a solution to persist the selected language after the page reloads. Any tips or suggestions would be greatly appreciated.
<form action="{% url 'set_language' %}" method="POST">
{% csrf_token %}
<input type="hidden" id="languageSwitcher" name="selected" value="{{ redirect_to}}">
<select name ="language" id="languageField">
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages%}
<option value="{{language.code}}" {% if language.code == LANGUAGE_CODE %} selected {% endif %}>
{{language.name_local}}
</option>
{% endfor %}
</select>
<input type="submit" id ="languageSwitcher" value="Change">
</form>