skip to navigation
skip to content

deform 2.0b3

Form library with advanced features like nested forms



Deform is a Python HTML form library independent of underlying web framework. Deform is ideal for complex server-side generated forms with JavaScript integration. More complex examples include nested forms where one can dynamically add and remove subform items. Date and time picking widgets and other rich widgets are supported out of the box.

Deform comes with Chameleon templates for Bootstrap based widgets. It uses Colander as for form schema and validation definitions. Deform integrates well with Pyramid web framework and several other web frameworks. Peppercorn library is used to convert flat HTML name value mapping form submissions to stream of name value mappings submissions, allowing building complex and nested form structure.

Even if Deform uses Chameleon templates internally, you can embed rendered Deform forms into any template language.


Example code:

"""Self-contained Deform demo example."""
from __future__ import print_function

from pyramid.config import Configurator
from pyramid.session import UnencryptedCookieSessionFactoryConfig
from pyramid.httpexceptions import HTTPFound

import colander
import deform

class ExampleSchema(deform.schema.CSRFSchema):

    name = colander.SchemaNode(

    age = colander.SchemaNode(
        help_text="Your age in years")

def mini_example(request):
    """Sample Deform form with validation."""

    schema = ExampleSchema().bind(request=request)

    # Create a styled button with some extra Bootstrap 3 CSS classes
    process_btn = deform.form.Button(name='process', title="Process")
    form = deform.form.Form(schema, buttons=(process_btn,))

    # User submitted this form
    if request.method == "POST":
        if 'process' in request.POST:

                appstruct = form.validate(request.POST.items())

                # Save form data from appstruct
                print("Your name:", appstruct["name"])
                print("Your age:", appstruct["age"])

                # Thank user and take him/her to the next page
                request.session.flash('Thank you for the submission.')

                # Redirect to the page shows after succesful form submission
                return HTTPFound("/")

            except deform.exception.ValidationFailure as e:
                # Render a form version where errors are visible next to the fields,
                # and the submitted values are posted back
                rendered_form = e.render()
        # Render a form with initial default values
        rendered_form = form.render()

    return {
        "rendered_form": rendered_form,

def main(global_config, **settings):
    """pserve entry point"""
    session_factory = UnencryptedCookieSessionFactoryConfig('seekrit!')
    config = Configurator(settings=settings, session_factory=session_factory)
    config.add_static_view('static_deform', 'deform:static')
    config.add_route('mini_example', path='/')
    config.add_view(mini_example, route_name="mini_example", renderer="templates/")
    return config.make_wsgi_app()


This library is actively developed and maintained.

2.0b3 (2016-10-22)

  • Update demos and add standalone mini example

2.0b2 (2016-10-22)

  • Fix README on PyPi

2.0b1 (2016-10-22)

2.0a2 (2013-10-18)

  • PasswordWidget and CheckedPasswordWidget have grown an additional argument/attribute named redisplay, which controls what happens on a validation failure of a form involving such a field. If redisplay is True (the default), the password will be re-rendered into the form when the form is re-rendered after validation failure. If redisplay is False, the password will not be re-rendered into the form. The default is False, which means that, as of this release, passwords will not be redisplayed; this changes the default behavior wrt previous releases. Values typed into password fields are not redisplayed by default during validation failure, as a security measure (the value winds up in browser history). Use PasswordWidget(redisplay=True) or CheckedPasswordWidget(redisplay=True) to make these widgets redisplay passwords on validation failures, matching the old behavior.
  • When using the default Chameleon template renderer, template names can now be “asset specifications” e.g. mypackage:subdir1/subdir2/ instead of extensionless paths relative to a search path. When template names are specified as asset specifications, the pkg_resources.resource_filename API is used to dereference them into an actual file path.

2.0a1 (2013-10-05)

This is an alpha release of Deform v2. Deform v2 is backwards incompatible with Deform v1. It requires the use of Twitter Bootstrap v3, whereas deform v1 did not require Bootstrap.

A demonstration site that shows Deform 2 in action exists at

Both Deform 1 and Deform 2 will be maintained going forward. If you wish to continue using Deform 1, because you cannot upgrade, or cannot depend on Bootstrap 3, please pin your deform distribution requirement to something below 2.0a1, e.g. deform<=1.999.

This first alpha release is missing formal documentation updates. Apologies, we needed to get a release out onto PyPI, as not having one is holding back the development of a number of platforms and applications that depend on the changes in v2+. Documentation updates will be forthcoming over the lifetime of future alpha/beta releases. However, below is a list of known issues that need to be addressed to make a final release of Deform 2, as well as information about new features, and migration notes. You may also be able to make use of the demo site at to divine how things have changed, and what CSS and JavaScript resources you’ll need to include in your pages to make use of this release.


  • docs
  • decide how to explain form.css (include in requirements or?)
  • horizontal/inline forms + structural things
  • assets for templates: deform should provide a tool to resolve that?
  • placeholder support for all textual inputs (and required/maxlength see also
  • display help-blocks for readonly fields?
  • maybe readonly should be a property of the schema, not the widget.
  • consider whether “style”/”css_class” on multi-input widgets should apply to a container or each element.
  • audit use of e.g. string:${css_class} so we don’t see unexpected class=”None” in widget rendering output.
  • some sort of test for mapping_item input_prepend/input_append
  • Currently description shows up as both tooltip of label and as help-block. Maybe make these two things separate or at least don’t show them both using the same value.
  • normalize CSS class names to deform-foo rather than deformFoo
  • sequence_of_sequences: js that processes close/order buttons has to be less promiscuous (it uses e.g. “find”); symptom: buttons appear/disappear, act on the wrong element, etc… ugh 2013/10/05 cannot replicate, but still believe there may be an issue, but maybe iElectric fixed it




  • removed deprecated height, width, skin, theme parameters from RichTextWidget (use “options” instead)
  • removed deprecated render_initial_item from SequenceWidget
  • removed deprecated deform.Set (use colander.Set instead)
  • DateInputWidget renamed parameter dateFormat to format (dateFormat now unsupported).
  • DateTimeInputWidget now renders as two fields: one for a date and one for a time, using pickadate.
  • We no longer bother trying to use the native datetimeinput widget on any browser, because the support is so spotty.
  • DateTimeInputWidget takes two options now: date_options and time_options instead of a single options dictionary. The options are pickadate date/time options respectively.
  • It is no longer possible to do DateTimeWidget().options[‘a’] = ‘foo’ or DateTimeWidget().date_options[‘a’] = ‘foo’. If you need to change options imperatively, set the entire .options/.date_options dictionary.
  • merged TypeaheadInputWidget to AutocompleteInputWidget (removed delay parameter)
  • AutocompleteInputWidget now accepts string type for “values”
  • widgets no longer accepts “size” (instead use style=”width: x”), except SelectWidget (it means the size of the dropdown)
  • get_widget_resources now returns asset specifications rather than deform-static-relative paths
  • deform 2.0 requires users to manually load TB 3.0 and jquery 2.0
  • required labels no longer insert an asterisk inside a <span class=”req”> inside themselves. instead the label element has a required class if the field is required; use form.css to display this as an asterisk.
  • min_length of AutocompleteInputWidget now defaults to 1 (was 2)
File Type Py Version Uploaded on Size
deform-2.0b3.tar.gz (md5) Source 2016-10-22 626KB