# API Bootstrap

class crispy_forms.bootstrap.Accordion(*accordion_groups, css_id=None, css_class=None, template=None, **kwargs)

  Accordion menu object. It wraps AccordionGroup objects in a container

  Parameters:
    *accordion_groups str, LayoutObject

      Any number of layout objects as positional arguments to be rendered within the `<div>`.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      Accordion(
          AccordionGroup("group name", "form_field_1", "form_field_2"),
          AccordionGroup("another group name", "form_field")
      )

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default None.

class crispy_forms.bootstrap.AccordionGroup(name, *fields, css_id=None, css_class=None, template=None, active=None, **kwargs)

  Accordion Group (pane) object. It wraps given fields inside an accordion tab. It takes accordion tab name as first argument.

  Tab object. It wraps fields in a div whose default class is “tab-pane” and takes a name as first argument.

  Parameters:
    name str

      The name of the container.

    *fields str, LayoutObject

      Any number of fields as positional arguments to be rendered within the container.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      AccordionGroup("group name", "form_field_1", "form_field_2")

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default “”.

class crispy_forms.bootstrap.Alert(content, dismiss=True, block=False, css_id=None, css_class=None, template=None, **kwargs)

  Generates markup in the form of an alert dialog.

  Parameters:
    content str

      The content of the alert.

    dismiss bool

      If true the alert contains a button to dismiss the alert. By default True.

    block str, optional

      Additional CSS classes to be applied to the `<button>`. By default None.

    css_id str, optional

      A DOM id for the layout object which will be added to the alert if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are then available in the template context.

  Examples

  Example:

      Alert(content='<strong>Warning!</strong> Best check yo self, you're not looking too good.')

  Attributes:
    template: str

      The default template which this Layout Object will be rendered with.

    css_class str

      The CSS classes to be applied to the alert. By defult “alert”.

class crispy_forms.bootstrap.AppendedText(field, text, *, input_size=None, active=False, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering a field with appended text.

  Parameters:
    field str

      The name of the field to be rendered.

    text str

      The appended text, can be HTML like.

    input_size str, optional

      For Bootstrap4+ additional classes to customise the input-group size e.g. `input-group-sm`. By default None

    active bool

      For Bootstrap3, a boolean to render the text active. By default `False`.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      AppendedText('amount', '.00')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.Container(name, *fields, css_id=None, css_class=None, template=None, active=None, **kwargs)

  Base class used for Tab and AccordionGroup, represents a basic container concept.

  Parameters:
    name str

      The name of the container.

    *fields str, LayoutObject

      Any number of fields as positional arguments to be rendered within the container.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default “”.

class crispy_forms.bootstrap.ContainerHolder(*fields, css_id=None, css_class=None, template=None, **kwargs)

  Base class used for TabHolder and Accordion, groups containers.

  Parameters:
    *fields str, LayoutObject

      Any number of fields or layout objects as positional arguments to be rendered within the `<div>`.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default None.

  first_container_with_errors(errors)

    Returns the first container with errors, otherwise returns None.

  open_target_group_for_form(form)

    Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False.

class crispy_forms.bootstrap.FieldWithButtons(*fields, input_size=None, css_id=None, css_class=None, template=None, **kwargs)

  A layout object for rendering a single field with any number of buttons.

  Parameters:
    *fields str or LayoutObject

      The first positional argument is the field. This can be either the name of the field as a string or an instance of Field. Following arguments will be rendered as buttons.

    input_size str

      Additional CSS class to change the size of the input. e.g. “input-group-sm”.

    css_id str, optional

      A DOM id for the layout object which will be added to the wrapping `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the wrapping `<div>`.

  Examples

  Example:

      FieldWithButtons(
          Field("password1", css_class="span4"),
          StrictButton("Go!", css_id="go-button"),
          input_size="input-group-sm",
      )

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the wrapping `<div>`. By default None.

class crispy_forms.bootstrap.FormActions(*fields, css_id=None, css_class=None, template=None, **kwargs)

  Bootstrap layout object. It wraps fields in a <div class=”form-actions”>

  Parameters:
    *fields HTML or BaseInput

      The layout objects to render within the `ButtonHolder`. It should only hold HTML and BaseInput inherited objects.

    css_id str, optional

      A custom DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied to the `<div>`. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  An example using `FormActions` in your layout:

      FormActions(
          HTML(<span style="display: hidden;">Information Saved</span>),
          Submit('Save', 'Save', css_class='btn-primary')
      )

  Attributes:
    template: str

      The default template which this Layout Object will be rendered with.

class crispy_forms.bootstrap.InlineCheckboxes(*fields, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering checkboxes inline.

  Parameters:
    *fields str

      Usually a single field, but can be any number of fields, to be rendered with the same attributes applied.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      InlineCheckboxes('field_name')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.InlineField(*fields, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering fields as Inline in bootstrap.

  Parameters:
    *fields str

      Usually a single field, but can be any number of fields, to be rendered with the same attributes applied.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      InlineField('field_name')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.InlineRadios(*fields, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering radiobuttons inline.

  Parameters:
    *fields str

      Usually a single field, but can be any number of fields, to be rendered with the same attributes applied.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      InlineRadios('field_name')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.Modal(*fields, template=None, css_id='modal_id', title='Modal Title', title_id='modal_title_id', css_class=None, title_class=None, **kwargs)

  Boostrap layout object for rendering crispy forms objects inside a bootstrap modal.

  Parameters:
    *fields str

      The fields to be rendered within the modal.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    css_id: str, optional

      The modal’s DOM id. By default `modal_id`.

    title: str, optional

      Text to display in the modal’s header which will be wrapped in an `<H5>` tag. By default `Modal Title`.

    title_id: str, optional

      The title’s DOM id. By default `modal_title_id`.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default None.

    title_class: str, optional

      Additional CSS classes to be applied to the title. By default None.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      Modal(
          'field1',
          Div('field2'),
          css_id="modal-id-ex",
          css_class="modal-class-ex,
          title="This is my modal",
      )

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

class crispy_forms.bootstrap.PrependedAppendedText(field, prepended_text=None, appended_text=None, input_size=None, *, active=False, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering a field with prepended and appended text.

  Parameters:
    field str

      The name of the field to be rendered.

    prepended_text str, optional

      The prepended text, can be HTML like, by default None

    appended_text str, optional

      The appended text, can be HTML like, by default None

    input_size str, optional

      For Bootstrap4+ additional classes to customise the input-group size e.g. `input-group-sm`. By default None

    active bool

      For Bootstrap3, a boolean to render the text active. By default `False`.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      PrependedAppendedText('amount', '$', '.00')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.PrependedText(field, text, *, input_size=None, active=False, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering a field with prepended text.

  Parameters:
    field str

      The name of the field to be rendered.

    text str

      The prepended text, can be HTML like.

    input_size str, optional

      For Bootstrap4+ additional classes to customise the input-group size e.g. `input-group-sm`. By default None

    active bool

      For Bootstrap3, a boolean to render the text active. By default `False`.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      PrependedText('amount', '$')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.

class crispy_forms.bootstrap.StrictButton(content, css_id=None, css_class=None, template=None, **kwargs)

  Layout object for rendering an HTML button in a `<button>` tag.

  Parameters:
    content str

      The content of the button. This content is context aware, to bring this to life see the examples section.

    css_id str, optional

      A custom DOM id for the layout object which will be added to the `<button>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied to the `<button>`. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to flatatt and converted into key=”value”, pairs. These attributes are added to the `<button>`.

  Examples

  In your `Layout`:

      StrictButton("button content", css_class="extra")

  The content of the button is context aware, so you can do things like:

      StrictButton("Button for {{ user.username }}")

  Attributes:
    template: str

      The default template which this Layout Object will be rendered with.

    field_classes str

      The CSS classes to be applied to the button. By defult “btn”.

class crispy_forms.bootstrap.Tab(name, *fields, css_id=None, css_class=None, template=None, active=None, **kwargs)

  Tab object. It wraps fields in a div whose default class is “tab-pane” and takes a name as first argument.

  Parameters:
    name str

      The name of the container.

    *fields str, LayoutObject

      Any number of fields as positional arguments to be rendered within the container.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      Tab('tab_name', 'form_field_1', 'form_field_2', 'form_field_3')

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default “”.

  render_link(template_pack=<SimpleLazyObject: <function get_template_pack>>, **kwargs)

    Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed.

class crispy_forms.bootstrap.TabHolder(*fields, css_id=None, css_class=None, template=None, **kwargs)

  TabHolder object. It wraps Tab objects in a container.

  Parameters:
    *fields str, LayoutObject

      Any number of fields or layout objects as positional arguments to be rendered within the `<div>`.

    css_id str, optional

      A DOM id for the layout object which will be added to the `<div>` if provided. By default None.

    css_class str, optional

      Additional CSS classes to be applied in addition to those declared by the class itself. By default None.

    template str, optional

      Overrides the default template, if provided. By default None.

    **kwargs dict, optional

      Additional attributes are passed to `flatatt` and converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      TabHolder(
          Tab('form_field_1', 'form_field_2'),
          Tab('form_field_3')
      )

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    css_class str, optional

      CSS classes to be applied to the `<div>`. By default None.

class crispy_forms.bootstrap.UneditableField(field, css_class=None, wrapper_class=None, template=None, **kwargs)

  Layout object for rendering fields as uneditable in bootstrap.

  Parameters:
    fields str

      The name of the field.

    css_class str, optional

      CSS classes to be applied to the field. These are added to any classes included in the `attrs` dict. By default `None`.

    wrapper_class: str, optional

      CSS classes to be used when rendering the Field. This class is usually applied to the `<div>` which wraps the Field’s `<label>` and `<input>` tags. By default `None`.

    template str, optional

      Overrides the default template, if provided. By default `None`.

    **kwargs dict, optional

      Additional attributes are converted into key=”value”, pairs. These attributes are added to the `<div>`.

  Examples

  Example:

      UneditableField('field_name', css_class="input-xlarge")

  Attributes:
    template str

      The default template which this Layout Object will be rendered with.

    attrs dict

      Attributes to be applied to the field. These are converted into html attributes. e.g. `data_id: 'test'` in the attrs dict will become `data-id='test'` on the field’s `<input>`.