- 摘要:1.下载安装 1)$easy_installdjango-extensions 2)在INSTALLED_APP中添加'django_extensions'[python]INSTALLED_APPS=( ... 'django_extensions', ) INSTALLED_APPS=(&nbs
-
1.下载安装
1)$ easy_install django-extensions
2)在INSTALLED_APP中添加'django_extensions'
[python]
INSTALLED_APPS = (
...
'django_extensions',
)INSTALLED_APPS = (
...
'django_extensions',
)2.'django_extensions'的runscript命令使用方法
方法1:在项目跟目录下创建scripts目录,创建__init__.py文件和运行脚本
testscript.py文件:
[python]
def run():
print 'I am a script'def run():
print 'I am a script'
方法2:也可以在项目的各个app中创建scripts文件夹,添加_init__.py文件盒运行脚本。runscript会搜索上诉两个地方的脚本。
3.运行方法:
对在根目录下的scripts方案:[python]
manage.py runscript testscriptmanage.py runscript testscript
对在各个app中的script:
[python]
manage.py runscript -v 2 testscriptmanage.py runscript -v 2 testscript