Opened 11 years ago

Closed 10 years ago

#3568 closed (wontfix)

Add support for serializing newforms to HTML

Reported by: Benjamin Hawkes-Lewis <bhawkeslewis@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords: newforms html xhtml
Cc: treborhudson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:


Currently, newforms only serializes to suit W3C's often-criticized Guidelines for serving XHTML 1.0 as text/html to buggy user agents. Its markup is not conformant with the HTML 4.01 specification, because according to HTML's SGML definition <input /> means <input>&gt; not <input>. My patch leaves the status quo as the default, but facilitates producing conformant HTML by adding an optional argument to the serialization methods. as_p(forms.SERIALIZATION_HTML401) for example. If there's a better way to achieve the same thing, that would be good too. It would also be nice to be able to set SERIALIZATION_DEFAULT app-wide, but I'm not sure how that's done. It may be that an end_empty_element() function would be useful elsewhere in Django too.

Attachments (2)

htmlnewforms.diff (15.6 KB) - added by Benjamin Hawkes-Lewis <bhawkeslewis@…> 11 years ago.
htmlnewforms.2.diff (16.4 KB) - added by Benjamin Hawkes-Lewis <bhawkeslewis@…> 11 years ago.
A couple fixes to my patch

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by Benjamin Hawkes-Lewis <bhawkeslewis@…>

Attachment: htmlnewforms.diff added

Changed 11 years ago by Benjamin Hawkes-Lewis <bhawkeslewis@…>

Attachment: htmlnewforms.2.diff added

A couple fixes to my patch

comment:1 Changed 11 years ago by Simon G. <dev@…>

Component: Core frameworkdjango.newforms
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 11 years ago by Chris Beaven

Patch needs improvement: set

Benjamin - you need to add your serializations package to SVN and create a new patch.

comment:3 Changed 11 years ago by Armin Ronacher

A big +1 for that. I would love to see HTML compatible forms in django.

comment:4 Changed 11 years ago by treborhudson@…

Cc: treborhudson@… added

Yes! Please! I avoid newforms b/c it outputs XHTML. It's trivial and anal, I know, but for us who think XHTML is "broken", please include this in Django!

comment:5 Changed 10 years ago by Jacob

Resolution: wontfix
Status: newclosed

We can't possibly include all the myriad ways someone might want to represent a form (XForms, anyone?). The as_* methods are shortcuts; nothing more. I'd consider an approach using a template filter here (i.e. {{ form|to_html }}).

Note: See TracTickets for help on using tickets.
Back to Top