views:

228

answers:

1

I'm trying to write a bat file so I can quickly launch into the Interactive Shell for one of my Django projects.

Basically I need to write a python script that can launch "manage.py shell" and then be able to print from mysite.myapp.models import *

The problem is manage.py shell cannot take additional arguments and launching into "manage.py shell" exits the parent script, so I am unable to then execute additional commands.

+2  A: 

First download django-extensions from google code. search for "django command-extensions"

Download and install it by running setup.py install from within the folder (it has a file called "setup.py") You will then be able to run manage.py shell_plus instead of manage.py shell, giving you an enhanced version of the python shell which will load all your models automatically

Now the batch file: make a new file "run_django.bat" on your desktop (for instance), then enter to it

@echo off
cd [path/to/project]
manage.py shell_plus

save the file. anytime you click it, it will start your shell with all your models loaded

bayo opadeyi
This looks incredible! thanks
KeyboardInterrupt