Geodjango Install on Windows Vista… what I’ve learned so far

It’s been a while since I installed Django on my Ubuntu laptop, and while my memory may betray me, I didn’t seem to be having too much trouble at the time. Having intensified my Python efforts lately, I thought I’d get Geodjango up and running on my Windows machine.

It’s been quite a trip, with too many starts and stops to count. I haven’t completely finished but a few lessons learned should be noted here before I forget. Plus someone else might find them helpful.

1) Essentially, I followed the instructions here (the for installation of Geodjango on Windows. The order of installation (whether required or merely advantageous) here was Python2.6 >> Postgresql8.3 >> Postgis1.3.6 >> Psycopg2 >> Geodjango, and I kept it that way. I already had Python installed, and didn’t re-install (more about that later…) I especially liked that the Geodjango installer takes care of all kinds of other nefarious installs for you (GDAL, PROJ4).

2) If you’re new to Postgres, which essentially I was/am, then it helps to know a bit about its database users. If you’re working on a desktop that’s not part of some *real* domain (like me, me@mycomputer), you’re most likely (able to become) the Administrator of your machine.  Run the postgres installer (exe/msi) as administrator, and follow the steps. When you’re prompted for a user name and password during the Postgres installation, go with the default ‘postgres’ and pick a password. Although you’re the one installing the software, you’re not automatically a user with permission to use the software (see item 4).

3) If you’re like me and you have more than one version of Python (e.g. 2.4, 2.5, 2.6, and 3.1) installed, make sure that Psycopg installs in the correct directory, i.e. the one for the version you’re going to be using with Django, in this case 2.6. Also your Windows PATH should include ‘c:\python26’, and I’m thinking that to avoid headaches, it should be listed in front c:\python25 and any other versions. More than likely, you’ll be having some issues with the paths.

To get to the Windows PATH, go to Control Panel .. System…Advanced… Environment Variables…PATH

To change Python’s search path for modules (sys.path, which is Python list):

import sys
print sys.path # This will allow you to look at the path

sys.path.append(‘your_mew_entry’) # to add items

4) Once everything was installed, I switched to these instructions of the  Geodjango Tutorial for configurations and setup. Once you’re ready to create a Postgres database, I think (and correct me if I’m wrong) it really doesn’t matter where you install your database. You initiate it with:

initdb -D <directory>

then you need to ‘become’ the postgres user ‘postgres’ to create it, use:

-U <yourname>, as in createdb -U <yourname> <yourproject> -T template_postgis geodjango

5) There is a good chance that you are much smarter than me or have more experience with Postgres and the Geodjango installation. But then, you probably wouldn’t be reading this. So, here is some more help. – If something fails in your initial Postgres install/setup, you will have to re-install. In that case, uninstall the program, delete the database folder, and then to delete the ‘postgres’ user you’ve created (and which Windows somehow doesn’t list under Users) do this:

net user <user> \delete

 Then you can start over.

6) When you’re Creating your Geodjango project, you might notice that the you installed looks different from the one in the tutorial.

    ‘default’: {
        ‘NAME’: ‘test_db’,
        ‘ENGINE’: ‘django.db.backends.postgresql_psycopg2’,
        ‘USER’: ‘myusername’,
        ‘PASSWORD’: ‘s3krit’,

instead of the following.

DATABASE_NAME = ‘geodjango’
DATABASE_ENGINE = ‘postgresql_psycopg2’
DATABASE_USER = ‘postgres’

Apparently, the former was version 1.1, the latter is version 1.2. I’m thinking (hoping) that merely replacing one with the other will do the trick. Can’t confirm this yet.

7) When it comes to Defining a Geographic Model, I copy/pasted the code from the tutorial into notepad, but then wasn’t sure what to save it as. The command python sqlall world, seems to imply it needs to be called Also, the module defines a class world_borders, and you should be expecting as outout something like “… world_worldborders…”. Anyway, this is how far I’ve gotten today. I am shooting for a clean, more successful run next time.


Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s