Opened 9 years ago

Closed 8 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@…> 9 years ago.
htmlnewforms.2.diff (16.4 KB) - added by Benjamin Hawkes-Lewis <bhawkeslewis@…> 9 years ago.
A couple fixes to my patch

Download all attachments as: .zip

Change History (7)

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

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

A couple fixes to my patch

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

  • Component changed from Core framework to django.newforms
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 9 years ago by SmileyChris

  • Patch needs improvement set

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

comment:3 Changed 8 years ago by Armin Ronacher

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

comment:4 Changed 8 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 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

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