@register.tag
def render_form_field(parser, token):
    try:
        help_text = None
        css_classes = None

        token_split = token.split_contents()
        if len(token_split) == 4:
            tag_name, form_field, help_text, css_classes = token.split_contents()
        elif len(token_split) == 3:
            tag_name, form_field, help_text = token.split_contents()
        else:
            tag_name, form_field = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError(
            "Unable to parse arguments for {0}".format(repr(token.contents.split()[0])))

    return FormFieldNode(form_field, help_text=help_text, css_classes=css_classes)
Usage is {% render_form_field form.field_name optional_help_text optional_css_classes %}
dataset/ETHPy150Open Tivix/django-common/django_common/templatetags/custom_tags.py/render_form_field