mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
magic-removal: updated session docs to reflect move of sessions to django.contrib.sessions.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1838 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
617f63a0f6
commit
c93965bbef
@ -16,11 +16,6 @@ You can turn session functionality on and off by editing the
|
|||||||
``MIDDLEWARE_CLASSES`` setting. To activate sessions, make sure
|
``MIDDLEWARE_CLASSES`` setting. To activate sessions, make sure
|
||||||
``MIDDLEWARE_CLASSES`` contains ``"django.middleware.sessions.SessionMiddleware"``.
|
``MIDDLEWARE_CLASSES`` contains ``"django.middleware.sessions.SessionMiddleware"``.
|
||||||
|
|
||||||
If you're dealing with an admin site, make sure the ``SessionMiddleware`` line
|
|
||||||
appears before the ``AdminUserRequired`` line. (The middleware classes are
|
|
||||||
applied in order, and the admin middleware requires that the session middleware
|
|
||||||
come first.)
|
|
||||||
|
|
||||||
If you don't want to use sessions, you might as well remove the
|
If you don't want to use sessions, you might as well remove the
|
||||||
``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES``. It'll save you a small
|
``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES``. It'll save you a small
|
||||||
bit of overhead.
|
bit of overhead.
|
||||||
@ -146,11 +141,11 @@ Using sessions out of views
|
|||||||
===========================
|
===========================
|
||||||
|
|
||||||
Internally, each session is just a normal Django model. The ``Session`` model
|
Internally, each session is just a normal Django model. The ``Session`` model
|
||||||
is defined in ``django/models/core.py``. Because it's a normal model, you can
|
is defined in ``django/contrib/sessions/models.py``. Because it's a normal
|
||||||
access sessions using the normal Django database API::
|
model, you can access sessions using the normal Django database API::
|
||||||
|
|
||||||
>>> from django.models.core import sessions
|
>>> from django.contrib.sessions.models import Session
|
||||||
>>> s = sessions.get_object(pk='2b1189a188b44ad18c35e113ac6ceead')
|
>>> s = Session.objects.get_object(pk='2b1189a188b44ad18c35e113ac6ceead')
|
||||||
>>> s.expire_date
|
>>> s.expire_date
|
||||||
datetime.datetime(2005, 8, 20, 13, 35, 12)
|
datetime.datetime(2005, 8, 20, 13, 35, 12)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user