Agnostic HTML in Django ¶
This page aims to document and discuss the output of either HTML4, HTML5, or XHTML from Django.
Background ¶
Currently, Django biased to producing XHTML output in the various places that output HTML, such as comments, formtools, CSRF, forms.widgets, and various filters and HTML utilities that output "<br />" tags. If someone prefers an HTML4 doctype, this is a hassle with no easy answer.
Some tickets already open on this...
- Ticket #6925: CSRF html output is not valid html (it is xhtml)
- Ticket #7281: Add doctype tag to webdesign template tags
- Ticket #7452: Settings for HTML4 or XHTML output
Some previous Django developer discussions...
- Mar 2008: Form rendering with filters
- Sept 2008: {% doctype %} and {% field %} tag for outputting form widgets as HTML or XHTML
- Sept 2009: Proposal: Better HTML4 Support
General Agreement ¶
The general agreement on the last Django developers discussion was:
- A way to output HTML4, HTML5, or XHTML would be preferred, with XHTML being the default for backwards compatibility.
- Having the choice at the template level is preferred to give designers the choice, and also allow different parts of a website to have different doctypes.
- Avoid another setting, for the above reason and others.
3rd Party Solutions ¶
- django-html http://github.com/simonw/django-html