I'm getting started with Django on Windows. And the tutorial http://docs.djangoproject.com/en/dev/intro/tutorial01/ has me running "python manage.py <command>" from a command promt all the time.

But I'm wondering: Couldn't I run the manage.py commands from PythonWin or IDLE?

Maybe something along these lines (prompt when running, after exit manage() command). It does bring up the terminal window.

# run_me.py
import os
def manage():
    s=' '
    print 'Finnish manage command by entering empty line.'
    while s<>'':
        os.chdir('d:\\Python Projects\mysite')
        if s: os.system('python manage.py '+s)

or you can use instead of os.system this Command from

class Command(object):
    """Run a command and capture it's output string, error string and exit status"""

    def __init__(self, command):
        self.command = command 

    def run(self, shell=True):
        import subprocess as sp
        process = sp.Popen(self.command, shell = shell, stdout = sp.PIPE, stderr = sp.PIPE)
        self.pid = process.pid
        self.output, self.error = process.communicate()
        self.failed = process.returncode
        return self

    def returncode(self):
        return self.failed

On Windows OS this behaves like double-clicking on the Python code file name ...

import os

I was thinking of something along the lines of Oracles ability to run SQL scripts from the SQL*Plus command line, like so:

SQL> start  script.sql  param1  param2

I guess what I'm asking is, if the Python command interpreter (and thereby PythonWin and IDLE) can do this:

>>> manage.py  syncdb

The more primitive solution:

# run_me.py
import os
def manage(s): os.system('python manage.py '+s)

## let's keep it working not only in windows

## after running this file you can use manage-command from IDLE command window
## but output goes to separate terminal window