How to keep a form's entered values when the user changes the website language via Django's i18n/setlang?

43 views Asked by At

I'm using Django 1.9.9 with the i18n set_language view to change website languages.

I have some pages with forms on them, e.g. for collecting project-specific user data. When a user enters data into such a form, but changes the language before saving the form, the entered data is lost.

Is there a way to prevent this from happening?

1

There are 1 answers

0
Udi On

You can write a small js event handler that on saves all the data in localstorage when clicking the set language link, and repopulates the form on page load.