The horizon.utils.fields Module

class horizon.utils.fields.IPField(*args, **kwargs)[source]

Bases: django.forms.fields.Field

Form field for entering IP/range values, with validation. Supports IPv4/IPv6 in the format: .. xxx.xxx.xxx.xxx .. xxx.xxx.xxx.xxx/zz .. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff .. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/zz and all compressed forms. Also the short forms are supported: xxx/yy xxx.xxx/yy

horizon.utils.fields.version

Specifies which IP version to validate, valid values are 1 (fields.IPv4), 2 (fields.IPv6) or both - 3 (fields.IPv4 | fields.IPv6). Defaults to IPv4 (1)

horizon.utils.fields.mask

Boolean flag to validate subnet masks along with IP address. E.g: 10.0.0.1/32

horizon.utils.fields.mask_range_from
Subnet range limitation, e.g. 16
That means the input mask will be checked to be in the range
16:max_value. Useful to limit the subnet ranges
to A/B/C-class networks.
IPField.clean(value)[source]
IPField.invalid_format_message = u'Incorrect format for IP address'
IPField.invalid_mask_message = u'Invalid subnet mask'
IPField.invalid_version_message = u'Invalid version for IP address'
IPField.max_v4_mask = 32
IPField.max_v6_mask = 128
IPField.validate(value)[source]
class horizon.utils.fields.SelectWidget(attrs=None, choices=(), data_attrs=(), transform=None)[source]

Bases: django.forms.widgets.Select

Customizable select widget, that allows to render data-xxx attributes from choices.

horizon.utils.fields.data_attrs

Specifies object properties to serialize as data-xxx attribute. If passed (‘id’, ), this will be rendered as: <option data-id=”123”>option_value</option> where 123 is the value of choice_value.id

horizon.utils.fields.transform

A callable used to render the display value from the option object.

SelectWidget.media
SelectWidget.render_option(selected_choices, option_value, option_label)[source]

Previous topic

The horizon.utils.html Module

Next topic

The horizon.utils.validators Module

This Page