Using pexpect to control Django manage.py
In the early stages of developing a Django application, I was deleting my sqlite database, and rerunning: python manage.py syncdb Every few minutes as the database models were changing. You might consider this some kind of evil thing to do, because we should all have our database models in concrete before writing any code but I am not that organised. One thing that was really distressing me was the fact that each time I ran a syncdb, I had to enter details for my default admin user. Username Email address Password Repeart Password This was fine for the first 400 times, then I got bored. The solution was to use pexpect. (There are probably command line options that you can give manage.py, but finding them out would have been more effort than this hack) Pexpect, http://pexpect.sourceforge.net/ is a pure python module for running external commands and controlling them as if you were a user. It has good documentation, and is perfect for needs of this nature. A quick browse through the exc...