django: 在命令行下执行的脚本

| No Comments | No TrackBacks

有个django的东东要写一个daemon来处理,这样就要在daemon script里初始化一个django environment,还好django提供了一个东东来设置这个environment.

import sys
sys.path.append('/home/guixing/Sites') #先要把自己的项目目录加入path
from django.core.management import setup_environ #这是重头戏,全靠它了
from myproject import settings #介绍自已人
setup_environ(settings) #安排自己人
#干活去吧

想干什么就干什么了,完全一样了。

No TrackBacks

TrackBack URL: http://mt.khsing.net/cgi-bin/mt-tb.cgi/13

Leave a comment

About this Entry

This page contains a single entry by Guixing published on March 24, 2008 5:28 PM.

补Moinmoin 小刀切切 was the previous entry in this blog.

SA的工作内容是什么 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.