@register.filter(name='crispy')
def as_crispy_form(form, template_pack=TEMPLATE_PACK, label_class='', field_class=''):
 if isinstance(form, BaseFormSet):
  template = uni_formset_template(template_pack)
  c = Context({'formset': form, 'form_show_errors': True, 'form_show_labels': True, 'label_class': label_class, 'field_class': field_class}).flatten()
 else:
  template = uni_form_template(template_pack)
  c = Context({'form': form, 'form_show_errors': True, 'form_show_labels': True, 'label_class': label_class, 'field_class': field_class}).flatten()
 return template.render(c)

@ register . filter ( name = 'crispy' ) def as_crispy_form ( form , template_pack = TEMPLATE_PACK , label_class = '' , field_class = '' ) : if isinstance ( form , BaseFormSet ) : template = uni_formset_template ( template_pack ) c = Context ( { 'formset' : form , 'form_show_errors' : True , 'form_show_labels' : True , 'label_class' : label_class , 'field_class' : field_class } ) . flatten ( ) else : template = uni_form_template ( template_pack ) c = Context ( { 'form' : form , 'form_show_errors' : True , 'form_show_labels' : True , 'label_class' : label_class , 'field_class' : field_class } ) . flatten ( ) return template . render ( c )
the original and still very useful way to generate a div elegant form/formset:: {% load crispy_forms_tags %} <form class="uniform" method="post"> {% csrf_token %} {{ myform|crispy }} </form> or .