Does this table need to be purged or is it taken care automatically by Django?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Django does NOT provide automatic purging. There is however a handy command available to help you do it manually: https://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-store
python manage.py clearsessions
回答2:
Django 1.6 or Above
python manage.py clearsessions
Django 1.5 or lower
python manage.py cleanup
From Django Shell
from django.contrib.sessions.models import Session
Session.objects.all().delete()
django-session-cleanup cornJob
回答3:
On my development server
, I prefer a database command over python manage.py clearsessions
because you delete all sessions, not just the expired ones (here: mysql). So login into your database and do:
truncate table django_session;
BTW, session
is not a database, but a table (django_session) and an app (django.contrib.sessions).