In Django, my .session request does not transfer ... does anyone know why?

In one view, I installed:

request.session.set_expiry(999)
request.session['test'] = '123'

In another form, I:

print request.session['test']

and it is impossible to find. (mistake) It's very simple, I have only 2 types.

It seems as soon as I leave my sight and return to him ... he is gone! Why?

+3
source share
2 answers

Could this be related to this ?, just found it at http://code.djangoproject.com/wiki/NewbieMistakes

Adding to list in session does not work

If you have a list in your session, add operations are not stored in the object. Decision

Copy the list from the session object, add it, and then copy back:

sessionlist = request.session['my_list']
sessionlist.append(new_object)
request.session['my_list'] = sessionlist
+13
source

, , -?

+1

Source: https://habr.com/ru/post/1731360/


All Articles