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. BetterForm with fieldsets and row_attrs by carljm 4 years, 3 months ago
  2. Form splitting/Fieldset templatetag by peritus 4 years, 8 months ago
  3. Add special field lookups to the Admin list_filter display by whiteinge 5 years, 3 months ago
  4. FieldsetForm by Ciantic 6 years, 1 month ago
  5. Fieldsets for Views by Nad/ 3 years, 4 months ago

Comments

pihentagy (on June 23, 2008):

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

#

(Forgotten your password?)