Different sessions for admin and applications in Django

后端 未结 3 444
广开言路
广开言路 2021-01-02 02:40

I\'d like to have different sessions for the Django admin interface and applications themselves to be able to login as admin to the admin interface and as a standard user to

3条回答
  •  孤城傲影
    2021-01-02 03:22

    You can also achieve this with two (very slightly different) settings files, each having a different session key name:

    In settings_app.py:

    SESSION_COOKIE_NAME = 'mysite_app'
    

    In settings_admin.py:

    SESSION_COOKIE_NAME = 'mysite_admin'
    

    I've found it useful to have different urls.py files too; while not strictly necessary, it does aid with separation of concerns.

提交回复
热议问题