@register.filter
def render_with_errors(bound_field):
 widget = bound_field.field.widget
 if (bound_field.errors and hasattr(widget, u'render_with_errors')):
  return widget.render_with_errors(bound_field.html_name, bound_field.value(), attrs={u'id': bound_field.auto_id}, errors=bound_field.errors)
 else:
  return bound_field.as_widget()

@ register . filter def render_with_errors ( bound_field ) : widget = bound_field . field . widget if ( bound_field . errors and hasattr ( widget , u'render_with_errors' ) ) : return widget . render_with_errors ( bound_field . html_name , bound_field . value ( ) , attrs = { u'id' : bound_field . auto_id } , errors = bound_field . errors ) else : return bound_field . as_widget ( )
usage: {{ field|render_with_errors }} as opposed to {{ field }} .