Django

Code

Ticket #3568 (closed: wontfix)

Opened 2 years ago

Last modified 1 year ago

Add support for serializing newforms to HTML

Reported by: Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com> Assigned to: nobody
Milestone: Component: Forms
Version: SVN Keywords: newforms html xhtml
Cc: treborhudson@gmail.com Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description

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

htmlnewforms.diff (15.6 kB) - added by Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com> on 02/24/07 15:48:41.
htmlnewforms.2.diff (16.4 kB) - added by Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com> on 02/24/07 16:15:36.
A couple fixes to my patch

Change History

02/24/07 15:48:41 changed by Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com>

  • attachment htmlnewforms.diff added.

02/24/07 16:15:36 changed by Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com>

  • attachment htmlnewforms.2.diff added.

A couple fixes to my patch

02/24/07 19:53:39 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • component changed from Core framework to django.newforms.
  • needs_tests changed.
  • needs_docs changed.

03/20/07 16:31:10 changed by SmileyChris

  • needs_better_patch set to 1.

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

10/22/07 17:18:40 changed by Armin Ronacher

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

11/26/07 11:24:05 changed by treborhudson@gmail.com

  • cc set to treborhudson@gmail.com.

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!

12/01/07 17:24:55 changed by jacob

  • status changed from new to closed.
  • resolution set to wontfix.

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 }}).


Add/Change #3568 (Add support for serializing newforms to HTML)




Change Properties
Action