dss
django-sage-session
pypi i django-sage-session
dss

django-sage-session

django-sage-cache is a great package for caching data in Django. In this package, an attempt has been made to use both private and shared caching techniques. Note that data caching is done at the database level. This is to reduce the number of queries to the database. The database we used to cache the data in this framework is called Redis.

by sageteam

0.1.0 (see all)License:GNU
pypi i django-sage-session
Readme

Django Sage Session

What is django-sage-session package?

django-sage-session is a useful package for per user session & private session in Django Web Framework

The Latest version of django-sage-session documentation

SageTeam

PyPI release Supported Python versions Supported Django versions Documentation

Project Detail

  • Language: Python > 3.5
  • Framework: Django > 3.1

Git Rules

S.A.G.E. team Git Rules Policy is available here:

Get Started

First install the package using pip:

$ pip install django-sage-session

Then add sage_cache to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'sage_session',
    ...
]

Usage

For using per user session you have to modify MIDDLEWARE in setting:

Replace django Session middleware with sage_session User Session middleware

MIDDLEWARE = [
    ...
    'django.middleware.security.SecurityMiddleware',
    'sage_session.middlewares.UserSessionMiddleware', # provided middleware for per user session
    # 'django.contrib.sessions.middleware.SessionMiddleware',
    ...
]

For activating Privacy session add it to MIDDLEWARE:

Add after UserSessionMiddleware

MIDDLEWARE = [
    ...
    'sage_session.middlewares.UserSessionMiddleware',  # user session
    'sage_session.middlewares.UserSessionPrivacyMiddleware',  # privacy session
    # 'django.contrib.sessions.middleware.SessionMiddleware',
    ...
]

Settings

PRIVACYSESSIONS_AUTHED_ONLY = False  # authentication required 
PRIVACYSESSIONS_PRIVACY_IP = True  # validate IP
PRIVACYSESSIONS_PRIVACY_UA = True  # validate user agent
PRIVACYSESSIONS_REMOTE_ADDR_KEY = 'REMOTE_ADDR'  # remote addr key in request (not recommended to change)
PRIVACYSESSIONS_REDIRECT_VIEW = None  # redirect view after logging out
PRIVACYSESSIONS_FAILURE_STATUS = 400 # if not PRIVACYSESSIONS_REDIRECT_VIEW set return status code
PRIVACYSESSIONS_IPV4_LENGTH = 32  # length of ipv4 (not recommended to change)
PRIVACYSESSIONS_IPV6_LENGTH = 64  # length of ipv6 (not recommended to change)
PRIVACYSESSIONS_IP_KEY = '_privacysessions_ip'  # ip key in session
PRIVACYSESSIONS_UA_KEY = '_privacysessions_ua'  # user agent key in session

Admin

sage_session also has an admin panel for User Session monitoring, It will activate when you add sage_session to INSTALLED_APPS

Team

Sepehr AkbarzadehMehran Rahmanzadeh
Sepehr Akbarazadeh MaintainerMehran Rahmanzadeh Maintainer

GitHub Stars

10

LAST COMMIT

1yr ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
0.1.0
1yr ago
No alternatives found
No tutorials found
Add a tutorial