# Path: crispy_forms/utils.py
# def get_template_pack():
#     return getattr(settings, "CRISPY_TEMPLATE_PACK", "bootstrap4")


from django import forms, template
from django.conf import settings
from django.template import Context, Variable, loader
from crispy_forms.utils import get_template_pack
def crispy_field(parser, token):
    """
    {% crispy_field field attrs %}
    """
    token = token.split_contents()
    field = token.pop(1)
    attrs = {}

    # We need to pop tag name, or pairwise would fail
    token.pop(0)
    for attribute_name, value in pairwise(token):
        attrs[attribute_name] = value

    return CrispyFieldNode(field, attrs)


@register.simple_tag()
def crispy_addon(field, append="", prepend="", form_show_labels=True):
    """
    Renders a form field using bootstrap's prepended or appended text::

        {% crispy_addon form.my_field prepend="$" append=".00" %}

    You can also just prepend or append like so

        {% crispy_addon form.my_field prepend="$" %}
        {% crispy_addon form.my_field append=".00" %}
    """
    if field:
        context = Context({"field": field, "form_show_errors": True, "form_show_labels": form_show_labels})

# Path: crispy_forms/utils.py
# def get_template_pack():
#     return getattr(settings, "CRISPY_TEMPLATE_PACK", "bootstrap4")


# Path: crispy_forms/templatetags/crispy_forms_field.py
from django import forms, template
from django.conf import settings
from django.template import Context, Variable, loader
from crispy_forms.utils import get_template_pack

def crispy_field(parser, token):
    """
    {% crispy_field field attrs %}
    """
    token = token.split_contents()
    field = token.pop(1)
    attrs = {}

    # We need to pop tag name, or pairwise would fail
    token.pop(0)
    for attribute_name, value in pairwise(token):
        attrs[attribute_name] = value

    return CrispyFieldNode(field, attrs)


@register.simple_tag()
def crispy_addon(field, append="", prepend="", form_show_labels=True):
    """
    Renders a form field using bootstrap's prepended or appended text::

        {% crispy_addon form.my_field prepend="$" append=".00" %}

    You can also just prepend or append like so

        {% crispy_addon form.my_field prepend="$" %}
        {% crispy_addon form.my_field append=".00" %}
    """
    if field:
        context = Context({"field": field, "form_show_errors": True, "form_show_labels": form_show_labels})

        template = loader.get_template("%s/layout/prepended_appended_text.html" % get_template_pack())