test.Client.session

Client.session

A dictionary-like object containing session information. See the session documentation for full details.

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):

1
2
3
4
def test_something(self):
    session = self.client.session
    session['somekey'] = 'test'
    session.save()
doc_Django
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.