Form row filter

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from django import template

register = template.Library()

@register.filter
def form_row(value):
        # Change the template string below to suit your needs.
	row = template.Template("""
	<div class="form-row{% if field.errors %} errors{% endif %}">
		{{ field.errors }}{{ field.label_tag }}{{ field }}
	</div>
	""")
	return row.render(template.Context({'field': value}))

More like this

  1. Fieldsets for Views by Nad/ 4 years, 3 months ago
  2. SectionedForm by marinho 5 years, 10 months ago
  3. BetterForm with fieldsets and row_attrs by carljm 5 years, 2 months ago
  4. Form splitting/Fieldset templatetag by peritus 5 years, 7 months ago
  5. FieldsetForm by Ciantic 7 years ago

Comments

pihentagy (on June 23, 2008):

Why not create a method like form.as_table()?

#

(Forgotten your password?)