=== added directory 'django/contrib/formtemplates'
=== added file 'django/contrib/formtemplates/__init__.py'
--- django/contrib/formtemplates/__init__.py	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/__init__.py	2008-10-08 15:46:46 +0000
@@ -0,0 +1,1 @@
+

=== added directory 'django/contrib/formtemplates/templates'
=== added file 'django/contrib/formtemplates/templates/form.html'
--- django/contrib/formtemplates/templates/form.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/form.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,5 @@
+{% extends base_template %}
+
+{% block content %}
+    {% include "parts/form-wrapper.html" %}
+{% endblock %}

=== added file 'django/contrib/formtemplates/templates/formset.html'
--- django/contrib/formtemplates/templates/formset.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/formset.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,5 @@
+{% extends base_template %}
+
+{% block content %}
+    {% include "parts/formset-wrapper.html" %}
+{% endblock %}

=== added directory 'django/contrib/formtemplates/templates/parts'
=== added file 'django/contrib/formtemplates/templates/parts/field-errors.html'
--- django/contrib/formtemplates/templates/parts/field-errors.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/field-errors.html	2008-10-08 15:46:45 +0000
@@ -0,0 +1,7 @@
+{% if field.errors %}
+    <ul class="errors">
+        {% for error in field.errors %}
+            <li>{{ error }}</li>
+        {% endfor %}
+    </ul>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/field-help-text.html'
--- django/contrib/formtemplates/templates/parts/field-help-text.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/field-help-text.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,3 @@
+{% if field.help_text %}
+    <p class="help-text">{{ field.help_text }}</p>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/field.html'
--- django/contrib/formtemplates/templates/parts/field.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/field.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,15 @@
+{% load forms %}
+{% if not field.is_hidden %}
+    {% if field.template %}
+        {% include field.template %}
+    {% else %}
+        <tr {{ field|attrs }}>
+            <th>{{ field|label_tag }}</th>
+            <td>
+                {% include "parts/field-errors.html" %}
+                {{ field }}
+                {% include "parts/field-help-text.html" %}
+            </td>
+        </tr>
+    {% endif %}
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/fieldset-legend.html'
--- django/contrib/formtemplates/templates/parts/fieldset-legend.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/fieldset-legend.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,3 @@
+{% if fieldset.legend %}
+    <legend>{{ fieldset.legend }}</legend>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/fieldset.html'
--- django/contrib/formtemplates/templates/parts/fieldset.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/fieldset.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,15 @@
+{% load forms %}
+<fieldset {{ fieldset|attrs }}>
+    {% include "parts/fieldset-legend.html" %}
+    <table>
+        {% ifequal fieldset.order 0 %}
+            {% include "parts/form-hidden.html" %}
+        {% endifequal %}
+        {% for field in fieldset.fields %}
+            {% include "parts/field.html" %}
+        {% endfor %}
+        {% if forloop.last %}
+            {% include "parts/form-submit.html" %}
+        {% endif %}
+    </table>
+</fieldset>

=== added file 'django/contrib/formtemplates/templates/parts/form-errors.html'
--- django/contrib/formtemplates/templates/parts/form-errors.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/form-errors.html	2008-10-08 15:46:45 +0000
@@ -0,0 +1,7 @@
+{% if form.non_field_errors %}
+    <ul class="errors non-field-errors">
+        {% for error in form.non_field_errors %}
+            <li>{{ error }}</li>
+        {% endfor %}
+    </ul>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/form-hidden.html'
--- django/contrib/formtemplates/templates/parts/form-hidden.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/form-hidden.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,9 @@
+<tr class="hidden">
+    <td colspan="2">
+        {% for field in form %}
+            {% if field.is_hidden %}
+                {{ field }}
+            {% endif %}
+        {% endfor %}
+    </td>
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/form-submit.html'
--- django/contrib/formtemplates/templates/parts/form-submit.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/form-submit.html	2008-10-08 15:46:45 +0000
@@ -0,0 +1,9 @@
+<tr class="submit">
+    <td colspan="2">
+        {% if submit_row %}
+            {{ submit_row }}
+        {% else %}
+            <input type="submit" value="{% trans 'Submit' %}"/>
+        {% endif %}
+    </td>
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/form-wrapper.html'
--- django/contrib/formtemplates/templates/parts/form-wrapper.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/form-wrapper.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,8 @@
+{% load forms %}
+{% if form.template %}
+    {% include form.template %}
+{% else %}
+    <form action="." method="post" {% if form.is_multipart %} enctype="multipart/form-data" {% endif %} {{ form|attrs }}>
+        {% include "parts/form.html" %}
+    </form>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/form.html'
--- django/contrib/formtemplates/templates/parts/form.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/form.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,28 @@
+{% include "parts/form-errors.html" %}
+{% if form.has_fieldsets %}
+    {% for fieldset in form.fieldsets %}
+        {% if fieldset.formset %}
+            {% with fieldset.formset as formset %}
+                {% if formset.template %}
+                    {% include formset.template %}
+                {% else %}
+                    {% include "parts/formset.html" %}
+                {% endif %}
+            {% endwith %}
+        {% else %}
+            {% if fieldset.template %}
+                {% include fieldset.template %}
+            {% else %}
+                {% include "parts/fieldset.html" %}
+            {% endif %}
+        {% endif %}
+    {% endfor %}
+{% else %}
+    <table>
+        {% include "parts/form-hidden.html" %}
+        {% for field in form %}
+            {% include "parts/field.html" %}
+        {% endfor %}
+        {% include "parts/form-submit.html" %}
+    </table>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset-errors.html'
--- django/contrib/formtemplates/templates/parts/formset-errors.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-errors.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,7 @@
+{% if formset.non_form_errors %}
+    <ul class="errors non-form-errors">
+        {% for error in formset.non_form_errors %}
+            <li>{{ error }}</li>
+        {% endfor %}
+    </ul>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset-field.html'
--- django/contrib/formtemplates/templates/parts/formset-field.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-field.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,12 @@
+{% load forms %}
+{% if not field.is_hidden %}
+    {% if field.template %}
+        {% include field.template %}
+    {% else %}
+        <td {{ field|attrs }}>
+            {% include "parts/field-errors.html" %}
+            {{ field }}
+            {% include "parts/field-help-text.html" %}
+        </td>
+    {% endif %}
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset-form-errors.html'
--- django/contrib/formtemplates/templates/parts/formset-form-errors.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-form-errors.html	2008-10-08 16:05:28 +0000
@@ -0,0 +1,12 @@
+{% load forms %}
+{% if form.non_field_errors %}
+    <tr class="errors non-field-errors">
+        <td colspan="{{ form|colspan }}">
+            <ul>
+                {% for error in form.non_field_errors %}
+                    <li>{{ error }}</li>
+                {% endfor %}
+            </ul>
+        </td>
+    </tr>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset-form.html'
--- django/contrib/formtemplates/templates/parts/formset-form.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-form.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,6 @@
+{% include "parts/formset-form-errors.html" %}
+<tr>
+    {% for field in form %}
+        {% include "parts/formset-field.html" %}
+    {% endfor %}
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/formset-header.html'
--- django/contrib/formtemplates/templates/parts/formset-header.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-header.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,7 @@
+<tr class="header">
+    {% for field in formset.forms.0 %}
+        {% if not field.is_hidden %}
+            <th>{{ field.label }}</th>
+        {% endif %}
+    {% endfor %}
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/formset-hidden.html'
--- django/contrib/formtemplates/templates/parts/formset-hidden.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-hidden.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,13 @@
+{% load forms %}
+<tr class="hidden">
+    <td colspan="{{ formset.forms.0|colspan }}">
+        {{ formset.management_form }}
+        {% for form in formset.forms %}
+            {% for field in form %}
+                {% if field.is_hidden %}
+                    {{ field }}
+                {% endif %}
+            {% endfor %}
+        {% endfor %}
+    </td>
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/formset-legend.html'
--- django/contrib/formtemplates/templates/parts/formset-legend.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-legend.html	2008-10-08 15:46:46 +0000
@@ -0,0 +1,3 @@
+{% if formset.legend %}
+    <legend>{{ formset.legend }}</legend>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset-submit.html'
--- django/contrib/formtemplates/templates/parts/formset-submit.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-submit.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,10 @@
+{% load forms %}
+<tr class="submit">
+    <td colspan="{{ formset.forms.0|colspan }}">
+        {% if submit_row %}
+            {{ submit_row }}
+        {% else %}
+            <input type="submit" value="{% trans 'Submit' %}"/>
+        {% endif %}
+    </td>
+</tr>

=== added file 'django/contrib/formtemplates/templates/parts/formset-wrapper.html'
--- django/contrib/formtemplates/templates/parts/formset-wrapper.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset-wrapper.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,8 @@
+{% load forms %}
+{% if formset.template %}
+    {% include formset.template %}
+{% else %}
+    <form action="." method="post" {% if formset.is_multipart %} enctype="multipart/form-data" {% endif %} {{ formset|attrs }}>
+        {% include "parts/formset.html" %}
+    </form>
+{% endif %}

=== added file 'django/contrib/formtemplates/templates/parts/formset.html'
--- django/contrib/formtemplates/templates/parts/formset.html	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templates/parts/formset.html	2008-10-08 16:05:27 +0000
@@ -0,0 +1,25 @@
+{% load forms %}
+<fieldset {{ formset|attrs }}>
+    {% include "parts/formset-legend.html" %}
+    {% include "parts/formset-errors.html" %}
+    <table>
+        {% include "parts/formset-hidden.html" %}
+        {% include "parts/formset-header.html" %}
+        {% for form in formset.forms %}
+            {% if form.template %}
+                {% include form.template %}
+            {% else %}
+                {% include "parts/formset-form.html" %}
+            {% endif %}
+            {% if forloop.parentloop %}
+                {% if forloop.parentloop.last and forloop.last %}
+                    {% include "parts/formset-submit.html" %}
+                {% endif %}
+            {% else %}
+                {% if forloop.last %}
+                    {% include "parts/formset-submit.html" %}
+                {% endif %}
+            {% endif %}
+        {% endfor %}
+    </table>
+</fieldset>

=== added directory 'django/contrib/formtemplates/templatetags'
=== added file 'django/contrib/formtemplates/templatetags/__init__.py'
=== added file 'django/contrib/formtemplates/templatetags/forms.py'
--- django/contrib/formtemplates/templatetags/forms.py	1970-01-01 00:00:00 +0000
+++ django/contrib/formtemplates/templatetags/forms.py	2008-10-08 16:05:27 +0000
@@ -0,0 +1,54 @@
+from django.forms.util import flatatt
+from django.utils.safestring import mark_safe
+from django.forms.forms import BaseForm, BoundField
+from django.forms.formsets import BaseFormSet
+import re
+
+from django.template import Library
+register = Library()
+
+html_class_re = re.compile(r'([a-z])([A-Z])')
+
+def attrs(input):
+    if isinstance(input, BaseForm):
+        if input.attrs:
+            return mark_safe(flatatt(input.attrs))
+        else:
+            return u''
+    elif isinstance(input, dict):
+        if input['attrs']:
+            return mark_safe(flatatt(input['attrs']))
+        else:
+            return u''
+    elif isinstance(input, BaseFormSet):
+        attrs = input.attrs and input.attrs.copy() or {}
+        class_attrs = attrs.get('class', '').split()
+        class_attrs.append('formset')
+        attrs['class'] = u' '.join(class_attrs)
+        return mark_safe(flatatt(attrs))
+    elif isinstance(input, BoundField):
+        attrs = input.attrs and input.attrs.copy() or {}
+        class_attrs = attrs.get('class', '').split()
+        class_attrs.append(html_class_re.sub(r'\1-\2', input.field.__class__.__name__).lower())
+        class_attrs.append(html_class_re.sub(r'\1-\2', input.field.widget.__class__.__name__).lower())
+        if input.field.required:
+            class_attrs.append(u'required')
+        if input.errors:
+            class_attrs.append(u'errors')
+        attrs['class'] = u' '.join(class_attrs)
+        return mark_safe(flatatt(attrs))
+    else:
+        raise ValueError
+attrs = register.filter(attrs)
+
+def label_tag(bf):
+    id = bf.field.widget.attrs.get('id') or bf.auto_id
+    if id:
+        return mark_safe(u'<label for="%s">%s:</label>' % (bf.field.widget.id_for_label(id), bf.label))
+    else:
+        return bf.label
+label_tag = register.filter(label_tag)
+
+def colspan(form):
+    return len([field for field in form if not field.is_hidden])
+colspan = register.filter(colspan)
\ No newline at end of file

