I'm a novice with Django and I'm trying to figure out how to save a class instance for the current user, exactly what I'm trying to do is to log my user to Firebase, and then, retrieve data from the database on firebase and save that data on a local class which is only going to be available until the user logout, but all my attempts save those class instances make them global (so actually they are accesible for every user and will overwrite the previous one).
My first attempt was on the views.py of my app, and looked like this:
APPMANAGER = FirebaseManager()
def homepage(request: HttpRequest) -> HttpResponse:
APPManager.loadData(request.POST.get("data"))
return HttpResponse("Done")
But that APPMANAGER
will be saved globally (and also will be erased if the server is rebooted).
I was checking also Django sessions (https://docs.djangoproject.com/en/2.2/topics/http/sessions/), which seem like what I want to do, but it just take data that is serializeable, and I want to save a custom class instance, what is the best approach to do this?