Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2013 21:31
What would you like to do?
Annotate a request object with session. Useful for requests that are generated by the RequestFactory for testing
from django.contrib.sessions.middleware import SessionMiddleware
def add_session_to_request(request):
"""Annotate a request object with a session"""
middleware = SessionMiddleware()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment