Overview

Django 1.0, released on September 3, 2008, is the first stable release of the most popular Python web framework. After several years of development and production use (notably at the Lawrence Journal-World where Django was born), this version marks the project's maturity and API stability.

Django stands out from the start with its "batteries included" philosophy: a powerful ORM, an automatic admin interface, a template engine, elegant URL routing, and a cohesive ecosystem that allows building complete web applications quickly.

Key Features

The Django ORM

Django's ORM lets you define data models in Python and manipulate them without writing SQL. Queries are chainable, lazy, and expressive.

python
from django.db import models

class Author(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField(unique=True)
    joined_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.name

class Article(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    published = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ['-created_at']

# Chainable and expressive queries
recent_articles = (
    Article.objects
    .filter(published=True)
    .select_related('author')
    .order_by('-created_at')[:5]
)

The admin interface

The Django admin automatically generates a full web interface for managing data. A few lines are enough to get a functional back-office with search, filters, and editing.

python
from django.contrib import admin

class ArticleAdmin(admin.ModelAdmin):
    list_display = ['title', 'author', 'published', 'created_at']
    list_filter = ['published', 'created_at']
    search_fields = ['title', 'content']
    date_hierarchy = 'created_at'

admin.site.register(Article, ArticleAdmin)

Templates and URL routing

The Django template engine separates presentation logic from Python code. The URL system lets you define elegant and readable routes.

python
# urls.py
from django.conf.urls import patterns, url

urlpatterns = patterns('',
    url(r'^articles/$', 'blog.views.article_list'),
    url(r'^articles/(?P<article_id>\d+)/$', 'blog.views.article_detail'),
)

# views.py
from django.shortcuts import render, get_object_or_404

def article_list(request):
    articles = Article.objects.filter(published=True)
    return render(request, 'blog/list.html', {'articles': articles})

def article_detail(request, article_id):
    article = get_object_or_404(Article, pk=article_id, published=True)
    return render(request, 'blog/detail.html', {'article': article})

Sources