3.18.2. Views

def index (request):
  "Display index page."
  authors = Author.objects.all ()
  return render_to_response ("index.html", {"authors" : authors})

def author (request, author_id):
  "Display author page."
  author = get_object_or_404 (Author, id = author_id)
  return render_to_response ("author.html", {"author" : author})

urlpatterns = patterns (
  "views",
  url (r"^$", "index", name="index"),
  url (r"^author/(?P<author_id>\d+)$", "author", name="author")
)