Extending the Session Middleware

不羁的心 提交于 2019-12-06 08:18:55

Looking at the documentation of SESSION_ENGINE, take such an example: django.contrib.sessions.backends.file. The source of this module defines a SessionStore class. So that's what you should do too:

./tcore/my_sessions.py:

from django.contrib.sessions.backends.db import SessionStore as DbSessionStore

class SessionStore(DbSessionStore):
    def __init__(self, *args, **kwargs):
        print 'hello from SessionStore'
        super(SessionStore, self).__init__(*args, **kwargs)

settings.py:

SESSION_ENGINE='tcore.my_sessions'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!