Friday, August 31, 2012

Modifying Dictionary in Django Session Does Not Modify Session

I think this is worth knowing because I spent quite a long time trying to debug a related issue.

This is the original post from SO. Read the whole thing. Very useful.

In short,

Whenever editing a session object, it is also required to explicitly say that the object was modified. This can be achieved like so:
request.session['xyz'] = 'xyz'
request.session.modfied = True
or in the settings we set,
SESSION_SAVE_EVERY_REQUEST True 
 .

No comments:

Post a Comment

Popular Posts