@register.filter(name='<STR_LIT>')<EOL>def as_crispy_field(field, template_pack=TEMPLATE_PACK, label_class="<STR_LIT>", field_class="<STR_LIT>"):
if not isinstance(field, forms.BoundField) and settings.DEBUG:<EOL><INDENT>raise CrispyError('<STR_LIT>')<EOL><DEDENT>attributes = {<EOL>'<STR_LIT>': field,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': label_class,<EOL>'<STR_LIT>': field_class,<EOL>}<EOL>helper = getattr(field.form, '<STR_LIT>', None)<EOL>template_path = None<EOL>if helper is not None:<EOL><INDENT>attributes.update(helper.get_attributes(template_pack))<EOL>template_path = helper.field_template<EOL><DEDENT>if not template_path:<EOL><INDENT>template_path = '<STR_LIT>' % template_pack<EOL><DEDENT>template = get_template(template_path)<EOL>c = Context(attributes).flatten()<EOL>return template.render(c)<EOL>
Renders a form field like a django-crispy-forms field::

    {% load crispy_forms_tags %}
    {{ form.field|as_crispy_field }}

or::

    {{ form.field|as_crispy_field:"bootstrap" }}