Reputation: 11
I'm new to django and I think sessions would be the best thing for my use case, but I'm not sure, maybe there are better possibilities?
This is my application simplified: Users should be able to select any number of train connections out of a database, and my application returns the best average mobile phone operator for their connections.
My models would be the following:
User, in which all the connections are saved
Connection, in which the quality of the mobile net for different operators is saved
And to save the users (and thus their choosen connections) I would have used sessions, which save the user_id.
Is this possible and recommended?
Upvotes: 1
Views: 699
Reputation: 2909
If you want the user's choices to persist longer than a single session, (i.e. I can come back to your app another time and be able to retrieve my choices), use a database to store it. You can look at https://tutorial.djangogirls.org/en/django_start_project/#set-up-a-database and https://tutorial.djangogirls.org/en/django_models/
Otherwise, if you do not want their choices to persist, then by all means use sessions.
Upvotes: 1