This is a piece of middleware for Django
which will let you serve all your pages as XHTML, with the correct
Content-Type header application/xhtml+xml, and automagically have the
pages served as HTML 4.01 Strict with Content-Type text/plain to browser
that don't understand XHTML.
The code is available on github.
Note: If you use the GZipMiddleware the XHTMLAsHTMLMiddleware must
come after the GZipMiddleware in your MIDDLEWARE_CLASSES.
The code is licensed under the X11 License (aka the MIT License).
There is a WSGI-version of the middleware.