1. Download and install
1) $ easy_install django-extensions
2) Add 'django _ extension' to INSTALLED_APP'
[Python]
INSTALLED_APPS = (
...
'Django _ extension ',
)
INSTALLED_APPS = (
...
'Django _ extension ',
)
2. How to Use the 'django _ extension' runscript command
Method 1: Create the scripts directory under the project and directory, create the _ init _. py file, and run the script.
Testscript. py file:
[Python]
Def run ():
Print 'I am a script'
Def run ():
Print 'I am a script'
Method 2: You can also create a scripts folder in each app of the project and add the _ init _. py file box to run the script. Runscript searches for scripts that appeal two places.
3. Running method:
For the scripts solution under the root directory:
[Python]
Manage. py runscript testscript
Manage. py runscript testscript
Script in each app:
[Python]
Manage. py runscript-v 2 testscript
Manage. py runscript-v 2 testscript