[Answer]-(How) can I set session data from inside a django test?

1👍

I don’t know which version of Django you use but in some old docs it is written:

To modify the session and then save it, it must be stored in a variable first (because a new SessionStore is created every time this property is accessed):

Example:

def test_something(self):
    session = self.client.session
    session['somekey'] = 'test'
    session.save()

docs

👤Mariy

Leave a comment