New runserver options for manage.py in Google App Engine Helper for Django

Update: Just as I was writing/releasing my patch, Matt Brown apparently committed r38 (diff) to the Google App Engine Helper for Django source tree which resolves the same issue -- and much more simply and elegantly than my solution, by using Django's own settings file. Use Matt's solution instead of my patch.

Original post follows:

The Google App Engine Helper for Django is an excellent library if you want to build Django apps on Google App Engine. I've been using it without any hassles on the new Singularity Web Conference site. One thing that it currently lacks, however, is a way to specify dev_appserver options (like smtp_host and smtp_port, for example) when you start the server.

So I got into the lazy habit of using dev_appserver.py to start the server when I needed to test email functionality and using ./manage.py runserver at other times.

Don't do this! :)

It started tripping me up because the two use different datastore instances. So I would do dumb things like run the server using dev_appserver.py and then start a shell with ./manage.py shell and wonder why certain entities were not in the datastore. Doh! :)

Instead, I'd recommend that you use manage.py for everything.

The problem then remains, how do you pass options to manage.py? Well, I just bit the bullet and added that functionality to the Google App Engine Helper for Django.

Here's the patch (runserver.patch.zip, 1kb).

After you apply it to your appengine_django folder, you will be able to pass the smtp_host and smtp_port options to the server just like you can with dev_appserver.py.

For example:

./manage.py runserver --smtp_host=localhost --smtp_port=5000 192.168.1.2:8080

I've only set those two options up because those are what I need at the moment but the code is flexible. Just add more valid dev_appserver.py options to the valid_args tuple in runserver.py and they'll automatically be proxied to the dev_appserver instance.