please I need some help, I have a web application with classic functionalities for users management (account creation, login,...). my problem is that I am trying to creat an instance of an object "UserObject" (not serializable object) for each user when he connects (login), this object will be used to process user requests in some views, so the object must be accessible from any view, for that i have a global dictionary "users_objects" in view.py that contains all users objects (the dictionary key is the user name and the value is the "UserObject" object), so view.py look lik this :
from user_object import UserObject
users_objects = {}
def login(request):
//login control and creation of session and context
......
......
global users_objects
user_name = request.session['name']
users_objects[user_name] = UserObject()
return render(request, 'mySite/home.html', context)
def request_view(request):
param = request.GET.get('parameter', None)
global users_objects
user_name = request.session['name']
obj = users_objects[user_name]
res = obj.process(param)
return HttpResponse(str(res))
This approach work fine with django dev-server, but when I configure django with a real production server (apache) the content of the global dictionary "users_objects" disappear and I get an empty dictionary. please, did anyone know why does this happen ?? and what is the best solution to use a global dictionary in django ?? thank you in advance