Setting Up A Database: Django - Src/django Django Site-Packages
Setting Up A Database: Django - Src/django Django Site-Packages
1. Make sure you have a Subversion client installed. You can get the software free from http://subversion.tigris.org/ and
excellent documentation from http://svnbook.red-bean.com/
2. Check out the trunk using the command svn co http://code.djangoproject.com/svn/django/trunk django_src
3. Symlink django_src/django so that django is within your Python site-packages directory, or update your PYTHONPATH to
point to it.
When installing from Subversion, you don’t need to run python setup.py install.
Because the Django trunk changes often with bug fixes and feature additions, you’ll probably want to update it every once in a
while — or hourly, if you’re really obsessed. To update the code, just run the command svn update from within the django_src
directory. When you run that command, Subversion will contact our Web server, see if any code has changed and update your
local version of the code with any changes that have been made since you last updated. It’s quite slick.
Setting up a database
Django’s only prerequisite is a working installation of Python. However, this book focuses on one of Django’s sweet spots, which
is developing database-backed Web sites — so you’ll need to install a database server of some sort, for storing your data.
If you just want to get started playing with Django, skip ahead to Starting a project, but trust us — you’ll want to install a
database eventually. All of the examples in the book assume you’ve got a database set up.
● PostgreSQL (http://www.postgresql.org/)
● SQLite 3 (http://www.sqlite.org/)
● MySQL (http://www.mysql.com/)
● Microsoft SQL Server (http://www.microsoft.com/sql/)
● Oracle (http://www.oracle.com/database/)
We’re quite fond of PostgreSQL ourselves, for reasons outside the scope of this book, so we mention it first. However, all those
engines will work equally well with Django.
SQLite also deserves special notice: It’s an extremely simple in-process database engine that doesn’t require any sort of server
set up or configuration. It’s by far the easiest to set up if you just want to play around with Django.
If you’re using PostgreSQL, you’ll need the psycopg package available from http://initd.org/projects/psycopg1. Make sure you
use version 1, not version 2 (which is still in beta).
If you’re using PostgreSQL on Windows, you can find precompiled binaries of psycopg at http://stickpeople.com/projects/python/
win-psycopg/.
You’ll need SQLite 3 — not version 2 — and the pysqlite package from http://initd.org/tracker/pysqlite. Make sure you
have pysqlite version 2.0.3 or higher.
Django requires MySQL 4.0 or above; the 3.x versions don’t support transactions, nested procedures, and some other fairly
standard SQL statements. You’ll also need the MySQLdb package from http://sourceforge.net/projects/mysql-python.
As mentioned above, Django doesn’t actually require a database. If you just want to use it to serve dynamic pages that don’t hit
a database, that’s perfectly fine.