Forms Layout


Layout object is the way to specify relative fields placements and sizes.

from material import *

layout = Layout(
    Row('shipment_no', 'description')
    Fieldset("Add to inventory",
             Row(Span3('product_name'), 'tags'),
             Row('vendor', 'product_type'),
                 'gender', 'desired_gender'),
             Row('cost_price', Span2('wholesale_price'), 'retail_price')))

SpanXX elements are not bound to the material grid classes but used to determine relative fields width. Each row occupies 12 grid columns. Elements in Row(‘elem1’, ‘elem2’) would be rendered in 6 grid columns each. In the Row(Span2(‘elem1’), ‘elem2’), elem1 would have eight grid columns and elem2 four grid columns.


class material.Layout(*elements)

Form layout specification.

Allows to set relative field sizes and positions.

class material.Span(span_columns, field_name)

Wrapper for a field reference.

There are Span2, Span3, .., Span12 shortcut classes. Layout autowraps string field references into Span(1, field_name)

  • span_columns – relative field width
  • field_name – field name in the form
render(context, **options)

Render field in the template.

Compatible with django {% include %} tag.

class material.Column(*elements, **kwargs)

Place elements vertically stacked, one under another.

Parameters:span_columns – Relative width of the fieldset
class material.Row(*elements, **kwargs)

Place elements in a single line.

class material.Fieldset(label, *elements, **kwargs)

Group of relative elements in a form.

  • label – Header for the fields group
  • span_columns – Relative width of the fieldset
class material.LayoutMixin

Extracts from layout fields for django FormView.

Shortcut allows don’t specify fields parameter in the GenericView if you already have layout object.


Provide list of field for ModelForm.