Introduction
Django is an open source web framework written in the Python programming language. Created by developers at a newspaper in Lawrence, Kansas, it was designed to alleviate many of the difficulties associated with the production of functional, scalable, and maintainable dynamic websites.
Unlike most open source projects, Django has excellent documentation which is actively maintained by the core developers. Two of the developers have also written the Django Book, which is published by Apress, and is freely available online today.
The official tutorial and the Django book do an excellent job of introducing fundamental concepts, and building toward a comprehensive understanding of the framework. If you want to learn the Django framework, they are required reading.
I hope this site can fill a slightly different role, presenting an introduction to the Django framework for complete beginners -- like me -- that is both simple to understand and interesting to read. This site is only an introduction, allowing readers to get their feet wet with the Django framework before they decide to invest the time and energy needed to master it.
In each chapter we will build a website with Django, carefully documenting all of the steps involved. Since I am not very clever we will reverse engineer popular sites that already exist, and implement them in Django. For example, in the first chapter we will build a simplified clone of Chicagocrime, a popular website that presents Google maps of crime in the city of Chicago.
Please note that Django is a moving target. While many websites have been created using Django, API stability cannot be gauranteed until the 1.0 release is finalized. I intend to update this text to remain current with the latest Django developments, but may lag behind at times. If you run into unexpected errors, check the backwards incompatible changes page on the Django wiki for clues.
No Installation Required
Users new to Django often find installation difficult, so I have created a simple standalone Django development setup that runs under Windows. I have tested it successfully with Windows XP and Windows 2000, and users have reported that it works under Windows Vista. It does not need to be installed, and can even be run from a USB key. This can be downloaded from the downloads page. The download is a self-extracting zip archive. After downloading, double click on the downloaded file to extract a folder named Django.
The standalone Django setup includes Python, Django, and several utilities to make development easier. The setup is launched by double-clicking on start.bat, which can be found in the root of the Django directory.
Several Windows environment variables are temporarily changed to allow Python and Django to operate correctly. The changes made to the environment variables should revert after you exit. If you already have Python installed on your computer, you may temporarily run into problems after using the standalone environment. If so, simply restart your computer. No permanent changes are made to your computer when you use the standalone environment.
As I noted earlier, Django is a moving target. Recent changes to the Django development branch are significant. Shortly, the way Django handles the administration interface will change, and work is still being done on the internals of database queries. The portable environment includes the latest development version available when I created the zip file, which could be out of date by the time you download it.
Upgrading to the latest version of trunk from the Django subversion repository is simple. Double click on start.bat, type update at the command prompt, and press enter. The update command takes some time to complete, depending on how many changes are downloaded, so be patient.
Conventions
The code samples in this text are displayed assuming that the reader is using the standalone Django environment provided on the downloads page. If you have installed Django on your own, the code you type should be very similar to the samples provided here, and easily translated to your environment.
Throughout this site, commands that you type at the command prompt will be appear with the following background color and font:
django-admin startproject crimemap
The output of commands will appear with the following background color and font:
Validating models...
Examples of source code will have the following appearance:
from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
def __str__(self):
return self.headline
Completed projects will be made available on the downloads page, if you are too lazy to do the typing yourself.
Odds & Ends
I have not yet determined how this site will be licensed. Most likely I will follow the example of the Django Book and release it under an open document license. For now, please feel free to read it, print it, and tell all your friends about it, but don't steal it and pretend you wrote it.
previous | next