Suppose I have some data in my view function that I want to use the next time I am in that function. The data is specific to each person that uses the website, so cannot be static or global, and it will change as the person uses the website. There are two methods I can think of to load this data into memory when the view function ends:
- Send it as part of the context each time a template is loaded from the view function, and then send it back to the view function via request.POST.
- Store it in the database and load it each time the view function is called.
The first one seems like it would be faster, but can be cumbersome if the data is complex.
Is there a third solution? What is the best practice? Is this what Django sessions are all about?