Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2 

3Abstract 

4-------- 

5 

6There are various things to remember when working with sessions in Django. This simple wrapper makes it easy to work 

7with a Django session in an object-oriented manner. 

8 

9Install 

10------- 

11 

12Other than `configuring Django sessions`_ there are no installation steps for this package. 

13 

14.. _configuring Django sessions: https://docs.djangoproject.com/en/stable/topics/http/sessions/ 

15 

16Usage 

17----- 

18 

19To use a session in a view: 

20 

21.. code-block:: python 

22 

23 from superdjango.sessions import Session 

24 

25 def my_view(request): 

26 session = Session(request, prefix="myapp") 

27 session.set("has_viewed_my_view", True) 

28 # ... 

29 

30 def my_other_view(request): 

31 session = Session(request, prefix="myapp") 

32 if not session.has("has_viewed_my_view"): 

33 redirect(reverse("my_view")) 

34 

35 # ... 

36 

37The ``prefix`` is optional, but helps prevent collisions. It's also handy when working with an app that has multiple 

38session variables. 

39 

40""" 

41__author__ = "Shawn Davis <shawn@superdjango.com>" 

42__maintainer__ = "Shawn Davis <shawn@superdjango.com>" 

43__version__ = "0.4.0-x" 

44 

45from .library import * 

46 

47__all__ = ( 

48 "Session", 

49)