Source code for templatetags.uni_form_filters
# -*- coding: utf-8 -*-
from django.conf import settings
from django.forms.formsets import BaseFormSet
from django.template import Context
from django.template.loader import get_template
from django import template
from uni_form.helpers import FormHelper
register = template.Library()
@register.filter
@register.filter
[docs]def as_uni_errors(form):
if isinstance(form, BaseFormSet):
template = get_template('uni_form/errors_formset.html')
c = Context({'formset': form})
else:
template = get_template('uni_form/errors.html')
c = Context({'form':form})
return template.render(c)
@register.filter
[docs]def as_uni_field(field):
template = get_template('uni_form/field.html')
c = Context({'field':field})
return template.render(c)
@register.inclusion_tag("uni_form/includes.html", takes_context=True)