python - How to pass variables between different view functions in Django -


some variables (class object) needs shared among different view functions. each view function changes object's properties. object user-specific, say, user needs log in web page, access different webpage. not want different users share/change object variable. can think of is:

  1. using global declare variable in different view functions. however, in running in django runserver multi-threaded, when multiple users access it, global variables changed/shared users? or variable specific each user?

  2. using session, however, variable object, not json serializable.

  3. store in database, however, object , not allowed store in database. cannot pickle either.

what correct way of sharing variables among different view functions while allowing multiple users access server concurrently?

thanks,

this problem met. please explain little bit, please not down vote without comment, thank you

you object user-specific. session-specific? if user open new tab in browser , access page in app, have 2 different objects? if so, makes sense store in session. can use pickle serialization around json (although can lead insecurities, if object user-provided.)


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -