Using session object in Django unit test
From the documentation for the RequestFactory
object:
It does not support middleware. Session and authentication attributes must be supplied by the test itself if required for the view to function properly.
You could try manually setting request.session
to be a dictionary with appropriate stuff in it, as you say. It might turn out to be easier to use the old-fashioned Django test client though.