Go Back   Cyber Tech Help Support Forums > Blogs > MishY

Notices

Rate this Entry

HOWTO: Install Django with Postgresql on Vista

Submit "HOWTO: Install Django with Postgresql on Vista" to Digg Submit "HOWTO: Install Django with Postgresql on Vista" to del.icio.us Submit "HOWTO: Install Django with Postgresql on Vista" to StumbleUpon Submit "HOWTO: Install Django with Postgresql on Vista" to Google
Posted August 30th, 2007 at 03:54 PM by MishY

About Django

The Django Website

Quote:
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Developed and used over two years by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.
Few notes about this howto

This howto describes the basics of getting django up and running on Vista. I wrote this because I couldn't find any one source that had everything I needed that was up2date. This tutorial does not cover many of Django, Python and Postgress intricacies but should be enough to get you started. I am currently learning Django, but am posting this in the hope it may be useful to someone.

Preparation

The first thing we need to do is download some software:

Postgresql
SVN
Python
MX-Extensions
Win-Pyscopg

Postgresql

Go to http://wwwmaster.postgresql.org/download/mirrors-ftp and pick the location closest to you.

You will need to download the win32 version of Postgres with the installer. At time of writing the file was called "postgresql-8.2.4-1.zip".

SVN

Because Django is always under heavy development it is advisable to install SVN so you can regularly update your copy of django easily.

You can get SVN from here: http://subversion.tigris.org/servlet...st?folderID=91

Get the latest version. At time of writing this was called "svn-1.4.5-setup.exe".

Python

You can get Python from here: http://www.python.org/download/

Download the Python 2.5.1 (or latest version) Windows installer.

MX-Extensions

Go here: http://www.egenix.com/products/python/

Click on the eGenix.com mx Base Distribution link.

Scroll down the next page to the downloads section. Here you should download the version that matches your Python version.

Win-Psycopg

You can get win-psycopg here: http://stickpeople.com/projects/python/win-psycopg/

Download the version that matches your Python version. Because I'm using Python 2.5.x I downloaded "win-psycopg25.zip".


Installation

Postgresql

Extract the Postgres zip to your desktop.

In order to install Postgres on Vista and not have to disable UAC, click from the start menu:

Start > Programs > Accessories.

Right click the Command Prompt shortcut and click "Run as Administrator", and then click "Continue" when prompted.

Navigate to your desktop folder.

Code:
cd c:\users\your username\Desktop
Then run the postgres msi (not the one that ends -int).

Code:
postgresql-8.2.msi
Progress through the wizard with its default options and specify both a password for the postgres user account that will run the postgres service, and also a password for the postgres database superuser.

SVN

Run the SVN exe. It should by default install to C:\Program Files\Subversion or C:\Program Files (x86)\Subversion for 64bit Vista users.

Python

Run the Python MSI. When I install Python I always install to C:\Python. It is important that you remember here where you install Python to.

MX-Extensions

Run the MX-Extensions MSI. It will ask you where to install it. This should be installed into your Python folder. ie. C:\Python (if you followed my preference).

Win-psycopg

Unzip the win-psycopg zip file to your desktop. Copy both the libpq.dll and pyscopg.pyd files into your Python\DLLs folder.

Important note on PATHs

Both Python and its scripts folder needed to be added to your PATH variable.

Hold down the Windows Key and press Pause Break.

Click the "Advanced System Settings" option from the sidebar of the window and continue on the following dialogue box.

Click on the "Environmental Variables" button.

From the 2nd Window that is entitled "System Variables" scroll down until you see Path.

Double click on PATH. A box will come up detailing the locations currently in your PATH variable.

Scroll to the end of that list and add the following:

Code:
;c:\Python\Scripts;c:\python
Note the ; at the start. Each location needs to be seperated by a ;

Please also note that you must alter the locations above if you chose not to install python as I have. For example it may need to be:

Code:
;c:\Python25\Scripts;c:\python25
If you followed the default Python install.

If your PATH variable already has a ; at the end you do not need to add it.

This is my PATH variable for example:

Quote:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;C:\Program Files (x86)\Subversion\bin;c:\Python\Scripts;c:\python
Now we can proceed with downloading Django.

Install Django

Close any command prompt windows you have open. Command prompt windows need to be closed and reopened after PATH changes.

Open up a command prompt (Start > Run > type "cmd" hit enter). Note that this command prompt does not require administrative priviledges.

Traverse to C:\

Code:
cd \
Type this into the command prompt:

Code:
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
SVN will then pull down the latest Django svn.

Now CD to the django_src folder.

Code:
cd django_src
Type the following to install Django.

Code:
python setup.py install
When the install has finished we'll CD back to C:\

Code:
cd \
Now create a Django folder.

Code:
mkdir django
and CD into this new folder.

Code:
cd django
We can now create our first django project:

Code:
django-admin.py startproject testproject
Now CD into the new project that has been setup by django:

Code:
cd testproject
The first thing to do to make sure that the project was setup ok is to run Djangos built in test server. To do this type:

Code:
python manage.py runserver
You should see a message like this:

Quote:
Validating models...
0 errors found.

Django version 0.97-pre-SVN-unknown, using settings 'myproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
To see your new project fire up a web browser and go to: http://127.0.0.1:8000/

You should be greeted with:

Quote:
It worked!
Congratulations on your first Django-powered page.
The install should now be completed so you can start your first project. I suggest following the tutorial on the Django website:

http://www.djangoproject.com/documentation/
Posted in Programming
Views 12403 Comments 0 Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 
Total Trackbacks 0

Trackbacks




All times are GMT +1. The time now is 04:57 AM.