My site allows individuals to contribute content in the absence of being logged in by creating a User based on the current session_key
I would like to setup a test for my view, but it seems that it is not possible to modify the request.session:
I'd like to do this:
from django.contrib.sessions.models import Session
s = Session()
s.expire_date = '2010-12-05'
s.session_key = 'my_session_key'
s.save()
self.client.session = s
response = self.client.get('/myview/')
But I get the error:
AttributeError: can't set attribute
Thoughts on how to modify the client session before making get requests?
I have seen this and it doesn't seem to work
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…