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
- 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)
- mask¶
Boolean flag to validate subnet masks along with IP address. E.g: 10.0.0.1/32
- 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.
- clean(value)[source]
- invalid_format_message = <django.utils.functional.__proxy__ object at 0xbceaf2c>
- invalid_mask_message = <django.utils.functional.__proxy__ object at 0xbcea12c>
- invalid_version_message = <django.utils.functional.__proxy__ object at 0xbceac6c>
- max_v4_mask = 32
- max_v6_mask = 128
- validate(value)[source]
- class horizon.utils.fields.MultiIPField(*args, **kwargs)[source]
Bases: horizon.utils.fields.IPField
Extends IPField to allow comma-separated lists of addresses.
- clean(value)[source]
- 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.
- 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
- transform¶
A callable used to render the display value from the option object.
- media
- render_option(selected_choices, option_value, option_label)[source]