The first Django site to run on Python 3!

The assertion

This page was generated by
Django 1.5.dev20120815104632
and
Python 3.2.3 (default, Aug 15 2012, 13:02:32) [GCC 4.4.5]
on Sept. 1, 2012, 3:42 p.m. (Paris time).

The proof

# The first Django site to run on Python 3!
# Copyright (c) 2012 Aymeric Augustin
# License: https://github.com/django/django/blob/master/LICENSE

import os
import sys

import django
from django.conf.urls.defaults import patterns
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseServerError
from django.template import Context, Template

# Settings

ROOT_URLCONF = os.path.splitext(os.path.basename(__file__))[0]
SECRET_KEY = "********"
TIME_ZONE = "Europe/Paris"

# View

TEMPLATE = """<html>
<head>
    <title>Django on Python 3!</title>
    <style type="text/css">
        body { font-family: Baskerville; margin: 2em auto; width: 42em; }
        h1, h2 { font-family: Verdana; color: #555; font-weight: normal; }
        p { text-align: center; line-height: 1.5em; }
        strong { color: #063; font-size: 120%; font-weight: normal; }
        pre { background-color: #ddd; color: #222; padding: 1em; }
    </style>
</head>
<body>
    <h1>The first Django site to run on Python 3!</h1>
    <h2>The assertion</h2>
    <p>This page was generated by<br>
        <strong>Django {{ versions.django }}</strong><br>
        and<br>
        <strong>Python {{ versions.python }}</strong><br>
        on {% now "DATETIME_FORMAT" %} (Paris time).
    </p>
    <h2>The proof</h2>
    <pre>{{ code }}</pre>
</body>
</html>"""

def index(request):
    with open(__file__) as handle:
        code = handle.read()
    return HttpResponse(Template(TEMPLATE).render(Context({
        'versions': {
            'django': django.get_version(),
            'python': sys.version,
        },
        'code': code.replace(SECRET_KEY, '********'),
    })))

# URL

urlpatterns = patterns('',
    (r'^$', index),
)

handler404 = lambda request: HttpResponseNotFound(
        '%r not found' % request.path, content_type='text/plain')

handler500 = lambda request: HttpResponseServerError(
        'something went wrong', content_type='text/plain')