这个表是需要清除还是由Django自动处理?
答案 0 :(得分:41)
Django不提供自动清除功能。但是,有一个方便的命令可以帮助您手动执行:https://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-store
python manage.py clearsessions
答案 1 :(得分:9)
Django 1.6或以上
static void Main(string[] args)
{
try
{
Bitmap bmp = null;
//The Source Directory in debug\bin\Big\
string[] files = Directory.GetFiles("Big\\");
foreach (string filename in files)
{
bmp = (Bitmap)Image.FromFile(filename);
bmp = ChangeColor(bmp);
string[] spliter = filename.Split('\\');
//Destination Directory debug\bin\BigGreen\
bmp.Save("BigGreen\\" + spliter[1]);
}
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
public static Bitmap ChangeColor(Bitmap scrBitmap)
{
//You can change your new color here. Red,Green,LawnGreen any..
Color newColor = Color.Red;
Color actualColor;
//make an empty bitmap the same size as scrBitmap
Bitmap newBitmap = new Bitmap(scrBitmap.Width, scrBitmap.Height);
for (int i = 0; i < scrBitmap.Width; i++)
{
for (int j = 0; j < scrBitmap.Height; j++)
{
//get the pixel from the scrBitmap image
actualColor = scrBitmap.GetPixel(i, j);
// > 150 because.. Images edges can be of low pixel color. if we set all pixel color to new then there will be no smoothness left.
if (actualColor.A > 150)
newBitmap.SetPixel(i, j, newColor);
else
newBitmap.SetPixel(i, j, actualColor);
}
}
return newBitmap;
}
Django 1.5或更低
python manage.py clearsessions
来自Django Shell
python manage.py cleanup
from django.contrib.sessions.models import Session
Django的会话清理 cornJob
答案 2 :(得分:1)
在development server
上,我更喜欢python manage.py clearsessions
上的数据库命令,因为你删除了所有会话,而不仅仅是过期的会话(这里是:mysql)。所以登录你的数据库并执行:
truncate table django_session;
BTW,session
不是数据库,而是表(django_session)和app(django.contrib.sessions)。