In Django, How to store user specific data?
I'm trying to creating a django web app, where user need to remember the order of random sequence fetched from database.
I have to functions in my views, home and result
I tried to store random sequence generated by home function into a global variable, and use that to validate in results function
But , I think this can serve only one user at time
What if second user requested for home page and that cause change in global variable, resulting unable to validate first user.
CodePudding user response:
You can tackle the problem with Django Session
.
In home view you can set variables by :
request.session['varibale_name'] = varibale_value
You can access these variables in result view by :
request.session['varibale_name']
After job done you can also delete the session variable by :
del request.session['varibale_name']