Django Template Controls Django templates to help construct common HTML controls.

The examples below use templates included from the sadjcore Django app.

You can use them just like any other Django templates, to quickly add common controls to your pages with reliable Smartadmin formatting and layout.

Alert Template

Django Template Entry

{% include 'sadjcore/controls/alert.html' with alert_class='m-0' alert_content='Your transaction has been successfully processed! Thank you for your purchase :)' %}
Your transaction has been successfully processed! Thank you for your purchase :)

Parameters (all optional)
  • alert_content - The content of the alert
  • alert_class - Sets additional class attributes
  • alert_type - Sets the alert type. One of 'success', 'info', 'warning', 'danger' (default: success)
  • alert_fixed - pass alert_fixed=1 to remove the 'dismiss' button. Defaults to a dissmissable alert with button.

Button Template

Django Template Entry

{% include 'sadjcore/controls/button.html' with with btn_id='button1' btn_size='lg' btn_content='Press Here' btn_icon='bolt' btn_title='Button generated from a template' %}

Parameters (all optional)
  • btn_content - The main button text
  • btn_id - Element ID (use to attach events via javascript)
  • btn_style - Sets the SmartAdmin button style. One of 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'dark', 'light' (default: primary)
  • btn_class - Sets additional class attributes
  • btn_size - Pass 'lg', 'sm' or 'xs' to change button size.
  • btn_type - Sets the type attribute (default: button).
  • btn_icon - Sets a Font Awesome icon within the button.
  • btn_title - Sets the button title (tooltip content).

Input Template

Django Template Entry

{% include 'sadjcore/controls/input.html' with ip_label='Email' ip_type='email' ip_name='email' ip_placeholder='Please enter a valid email' ip_help='Inspect element to view generated HTML' ip_grouped=1 ip_id='email-input' %}
Inspect element to view generated HTML

Parameters (all optional)
  • ip_label - The associated label content
  • ip_id - Sets id attribute
  • ip_name - Sets name attribute
  • ip_type - Sets type attribute
  • ip_value - Sets value attribute
  • ip_placeholder - Sets placeholder attribute
  • ip_help - Sets the help text below the control
  • ip_class - Sets class attributes (default: bg-success-50)
  • ip_required - Set ip_required=1 to include a required="true" attribute
  • ip_grouped - Whether to wrap the input into a div.form-group element.