Develop Django on Linux, View on Windows with Putty Port-forwarding
I have an on-going project to integrate a Windows Desktop application (namely, QuickBooks) with web applications built on Django.There are two issues with this:
- The QuickBooks Web Connector requires valid certificate HTTPS connections, except for testing–in which case you can use http://127.0.0.1:8000 (and other ports, presumably).
- I prefer to develop on Linux.
To date, I have done most of my Django development on the Windows box itself. Django runs just fine on Windows. However, getting all the dependencies on Windows can be a real pain. I did find some pre-compiled binaries, so I was able to make this work. But it wasn’t really satisfactory, IMHO.
Putty to the rescue!
I tried this before, a while ago, but couldn’t get it working. Today, I figured it out. I’m sharing it, in case you run into the same situation.
Setup port-forwarding on Windows
In Putty, you have to add a port-forwarding link. Here’s what it looks like:
IMPORTANT: Don’t forget to click “Add”!
When you start this connection, you can view the Event Log to verify that the port-forwarding worked. (Thanks to http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter3.html#3.5)
Run Django on a network-accessible IP address
Typically, you run Django on http://127.0.0.1:8000. But that’s not accessible to the network. Instead, you should run the server on its network address:
$ python manage.py runserver 192.168.1.102:8000
Or, use this shortcut (thanks to CGD):
$ python manage.py runserver 0.0.0.0:8000
Connect!
Now, on your Windows box, you can browse to http://127.0.0.1:8000 and it will hit your Django server running on Linux.