Commits

Benoît Bryon committed 3207c31

Added as_p, as_ul and as_table examples in demo project.

Comments (0)

Files changed (9)

demo/demoapp/templates/demoapp/base.html

     {% block content %}{% endblock content %}
     <div id="menu" style="clear:both;">
       <h2>{% trans "Table of contents" %}</h2>
-        <h3><a href="{% url demoapp:simple %}">{% trans "Simplest use case" %}</a></h3>
-        <h3><a href="{% url demoapp:errors %}">{% trans "Displaying errors" %}</a></h3>
+        <h3>{% trans "Basic usage" %}</h3>
+          <h4><a href="{% url demoapp:simple %}">{% trans "Simplest use case" %}</a></h4>
+          <h4><a href="{% url demoapp:errors %}">{% trans "Displaying errors" %}</a></h4>
+        <h3>{% trans "Reproducing builtins output" %}</h3>
+          <h4><a href="{% url demoapp:as_table %}">{% trans "as_table" %}</a></h4>
+          <h4><a href="{% url demoapp:as_ul %}">{% trans "as_ul" %}</a></h4>
+          <h4><a href="{% url demoapp:as_p %}">{% trans "as_p" %}</a></h4>
     </div>
   </body>
 </html>

demo/demoapp/templates/demoapp/includes/as_p_builtin.html

+<form>
+  {{ form.as_p }}
+  <input type="submit">
+</form>

demo/demoapp/templates/demoapp/includes/as_p_formrenderingtools.html

+{% load form_layouts %}
+
+<form>
+  {% form layout="as_p" %}
+  <input type="submit">
+</form>

demo/demoapp/templates/demoapp/includes/as_table_builtin.html

+<form>
+  <table>
+    {{ form.as_table }}
+  </table>
+  <input type="submit">
+</form>

demo/demoapp/templates/demoapp/includes/as_table_formrenderingtools.html

+{% load form_layouts %}
+
+<form>
+  <table>
+    {% form layout="as_table" %}
+  </table>
+  <input type="submit">
+</form>

demo/demoapp/templates/demoapp/includes/as_ul_builtin.html

+<form>
+  <ul>
+    {{ form.as_ul }}
+  </ul>
+  <input type="submit">
+</form>

demo/demoapp/templates/demoapp/includes/as_ul_formrenderingtools.html

+{% load form_layouts %}
+
+<form>
+  <ul>
+    {% form layout="as_ul" %}
+  </ul>
+  <input type="submit">
+</form>

demo/demoapp/urls.py

 urlpatterns += patterns('demo.demoapp.views',
     url(r'^simple/$', 'simple', name='simple'),
     url(r'^errors/$', 'errors', name='errors'),
+    url(r'^as-table/$', 'as_table', name='as_table'),
+    url(r'^as-ul/$', 'as_ul', name='as_ul'),
+    url(r'^as-p/$', 'as_p', name='as_p'),
+    
 )

demo/demoapp/views.py

     form = FakeContactForm({'subject': u''})
     template = 'errors'
     return comparison_page(request, title, description, form, template)
+
+
+def as_table(request):
+    title = _("Reproducing form.as_table")
+    description = _("Want to reproduce some form.as_table behaviour for backward compatibility? No problem! Notice that 'as_table' is the default for Django builtins, so {% form layout='as_table' %} reproduces both {{ form }} and {{ form.as_table }}.")
+    form = FakeContactForm({'subject': u''})
+    template = 'as_table'
+    return comparison_page(request, title, description, form, template)
+
+
+def as_ul(request):
+    title = _("Reproducing form.as_ul")
+    description = _("Want to reproduce some form.as_ul behaviour for backward compatibility? No problem!")
+    form = FakeContactForm({'subject': u''})
+    template = 'as_ul'
+    return comparison_page(request, title, description, form, template)
+
+
+def as_p(request):
+    title = _("Reproducing form.as_p")
+    description = _("Want to reproduce some form.as_p behaviour for backward compatibility? No problem!")
+    form = FakeContactForm({'subject': u''})
+    template = 'as_p'
+    return comparison_page(request, title, description, form, template)