views:

161

answers:

2

When I run manage.py shell on my Django project to take a peek at something there are common imports that I always want to run at the start of the shell (e.g. I always want to import my model files.) How can I have these run automatically everytime I run the shell command?

2nd related question, when I hit the up arrow I get the "^A" character instead of the previously run command in the manage.py shell (and in my regular python shell), how can I fix this so it loads the previous command like on the Linux/Unix command line?

+1  A: 

For the first question, look at the manage.py shell_plus command provided by the django-extensions project. It will load all your model files on shell startup. The project has got a whole load of other useful tricks too, so it's definitely worth checking out.

For the second question, I can only guess that you need to install readline.

Daniel Roseman
+1  A: 

One single thing which can solve both of your problem is ipython. ipython stores the previous executions and it can give you completion as well.

Prashanth