Class that describes a field, i.e. what input controls to render, the label, etc.

Note that, in addition to the parameters with the defined behavior below, you can pass in any keyword argument you need yourself, including callables that conform to the protocol, and they will be added and evaluated as members.

All these parameters can be callables, and if they are, will be evaluated with the keyword arguments form and field. The only exceptions are is_valid (which gets form, field and parsed_data), render_value (which takes form, field and value) and parse (which gets form, field, string_value). Example of using a lambda to specify a value:

Field(id=lambda form, field: 'my_id_%s' %

Refinable members

  • after
  • attr
    the attribute path to apply or get the data from. For example using “foo__bar__baz” will result in will be set by the apply() function. Defaults to same as name
  • attrs
    a dict containing any custom html attributes to be sent to the input_template.
  • choice_to_option
  • choice_tuples
  • choices
  • container
  • display_name
  • editable
    default: True
  • empty_choice_tuple
  • empty_label
  • endpoint
  • endpoint_dispatch
  • endpoint_path
  • errors_template
    django template filename for the template for just the errors output. Default: ‘tri_form/errors.html’
  • extra
  • help_text
    The help text will be grabbed from the django model if specified and available. Default: lambda form, field: ‘’ if form.model is None else form.model._meta.get_field_by_name([0].help_text or ‘’
  • id
    the HTML id attribute. Default: ‘id_%s’ % name
  • initial
    initial value of the field
  • initial_list
  • input_container
  • input_template
    django template filename for the template for just the input control. Default: ‘tri_form/input.html’
  • input_type
    the type attribute on the standard input HTML tag. Default: ‘text’
  • is_boolean
  • is_list
    interpret request data as a list (can NOT be a callable). Default False
  • is_valid
    validation function. Should return a tuple of (bool, reason_for_failure_if_bool_is_false) or raise ValidationError. Default: lambda form, field, parsed_data: (True, ‘’)
  • label_container
  • label_template
    django template filename for the template for just the label tab. Default: ‘tri_form/label.html’
  • model
  • model_field
  • name
    the name of the field. This is the key used to grab the data from the form dictionary (normally request.GET or request.POST)
  • parse
    parse function. Default just returns the string input unchanged: lambda form, field, string_value: string_value
  • parse_empty_string_as_none
  • post_validation
  • raw_data
  • raw_data_list
  • read_from_instance
    callback to retrieve value from edited instance. Invoked with parameters field and instance.
  • render_value
    render the parsed and validated value into a string. Default just converts to unicode: lambda form, field, value: unicode(value)
  • render_value_list
  • required
    if the field is a required field. Default: True
  • show
  • strip_input
    runs the input data through standard python .strip() before passing it to the parse function (can NOT be callable). Default: True
  • template
    django template filename for the entire row. Normally you shouldn’t need to override on this level, see input_template, label_template and error_template below. Default: ‘tri_form/{style}_form_row.html’
  • template_string
    You can inline a template string here if it’s more convenient than creating a file. Default: None
  • write_to_instance
    callback to write value to instance. Invoked with parameters field, instance and value.


  • editable
    • True
  • endpoint__config
    • tri_form.default_endpoint__config
  • endpoint__validate
    • tri_form.default_endpoint__validate
  • errors_template
    • tri_form/errors.html
  • input_template
    • tri_form/input.html
  • input_type
    • text
  • is_boolean
    • False
  • is_list
    • False
  • label_container__attrs__class__description_container
    • True
  • label_template
    • tri_form/label.html
  • parse_empty_string_as_none
    • True
  • required
    • True
  • show
    • True
  • strip_input
    • True
  • template
    • tri_form/{style}_form_row.html





Shortcut for single choice field. If required is false it will automatically add an option first with the value ‘’ and the title ‘—’. To override that text pass in the parameter empty_label.
param empty_label:
 default ‘—’
param choices:list of objects
param choice_to_option:
 callable with three arguments: form, field, choice. Convert from a choice object to a tuple of (choice, value, label, selected), the last three for the <option> element












Shortcut to create an info entry.