I have a Django view, where the user can choose between 2 different "views" of a list through a toggle button. The map view where a map is displayed with markers and some information and a list view where a list is displayed with the same information but with a list view.
When the user clicks the toggle button between one or another option, there is no problem, because I implemented an onClick Javascript function where I change the style display, and that works perfect, the problem is when the user reloads the page.
supposes that I put by default the map view, but the user change to the list view by clicking the toggle button, now if he/she reload the page, the view will have to be the list view, I know that I can accomplish this using a cookie but I don't know how to implement the update of the cookie every time the user clicks one of the toggle buttons with vanilla Javascript or in my python view.
I know that one solution may be creating 2 Django views one "mapView" and another "listView" so when you click the buttons take to another URL, but I want to load all the information and have the possibility to do it without this solution.
I also upload a GIF of how it works right now. I clicked the map view, reload the page, and change to the list view again.
Thank you!
I use a Javascript function to save a cookie with the view and solve this.