The horizon.forms Module

class horizon.forms.SelfHandlingMixin(request, *args, **kwargs)

Bases: object

class horizon.forms.SelfHandlingForm(request, *args, **kwargs)

Bases: horizon.forms.base.SelfHandlingMixin, django.forms.forms.Form

A base Form class which includes processing logic in its subclasses.

SelfHandlingForm.api_error(message)

Adds an error to the form’s error dictionary after validation based on problems reported via the API. This is useful when you wish for API errors to appear as errors on the form rather than using the messages framework.

SelfHandlingForm.base_fields = {}
SelfHandlingForm.media
SelfHandlingForm.required_css_class = 'required'
SelfHandlingForm.set_warning(message)

Sets a warning on the form.

Unlike NON_FIELD_ERRORS, this doesn’t fail form validation.

class horizon.forms.DateForm(*args, **kwargs)

Bases: django.forms.forms.Form

A simple form for selecting a range of time.

DateForm.base_fields = {'start': <django.forms.fields.DateField object at 0x447c410>, 'end': <django.forms.fields.DateField object at 0x447c4d0>}
DateForm.media
class horizon.forms.ModalFormView(**kwargs)

Bases: horizon.forms.views.ModalFormMixin, django.views.generic.edit.FormView

The main view class from which all views which handle forms in Horizon should inherit. It takes care of all details with processing SelfHandlingForm classes, and modal concerns when the associated template inherits from horizon/common/_modal_form.html.

Subclasses must define a form_class and template_name attribute at minimum.

See Django’s documentation on the FormView class for more details.

ModalFormView.cancel_label = <django.utils.functional.__proxy__ object at 0x4506710>
ModalFormView.cancel_url = None
ModalFormView.form_valid(form)
ModalFormView.get_cancel_url()
ModalFormView.get_context_data(**kwargs)
ModalFormView.get_form(form_class)

Returns an instance of the form to be used in this view.

ModalFormView.get_object_display(obj)

For dynamic insertion of resources created in modals, this method returns the display name of the created object. Defaults to returning the name attribute.

ModalFormView.get_object_id(obj)

For dynamic insertion of resources created in modals, this method returns the id of the created object. Defaults to returning the id attribute.

ModalFormView.submit_label = <django.utils.functional.__proxy__ object at 0x44f1f50>
class horizon.forms.ModalFormMixin

Bases: object

ModalFormMixin.get_context_data(**kwargs)
ModalFormMixin.get_template_names()
class horizon.forms.DynamicTypedChoiceField(add_item_link=None, add_item_link_args=None, *args, **kwargs)

Bases: horizon.forms.fields.DynamicChoiceField, django.forms.fields.TypedChoiceField

Simple mix of DynamicChoiceField and TypedChoiceField.

class horizon.forms.DynamicChoiceField(add_item_link=None, add_item_link_args=None, *args, **kwargs)

Bases: django.forms.fields.ChoiceField

A subclass of ChoiceField with additional properties that make dynamically updating its elements easier.

Notably, the field declaration takes an extra argument, add_item_link which may be a string or callable defining the URL that should be used for the “add” link associated with the field.

DynamicChoiceField.widget

alias of DynamicSelectWidget

class horizon.forms.IPField(*args, **kwargs)

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.forms.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.forms.mask

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

horizon.forms.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)
IPField.invalid_format_message = <django.utils.functional.__proxy__ object at 0x447ca90>
IPField.invalid_mask_message = <django.utils.functional.__proxy__ object at 0x447cb90>
IPField.invalid_version_message = <django.utils.functional.__proxy__ object at 0x447cb10>
IPField.max_v4_mask = 32
IPField.max_v6_mask = 128
IPField.validate(value)
class horizon.forms.MultiIPField(*args, **kwargs)

Bases: horizon.forms.fields.IPField

Extends IPField to allow comma-separated lists of addresses.

MultiIPField.clean(value)
MultiIPField.validate(value)
class horizon.forms.Field(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)

Bases: object

Field.bound_data(data, initial)

Return the value that should be shown for this field on render of a bound form, given the submitted POST data for the field and the initial data, if any.

For most fields, this will simply be data; FileFields need to handle it a bit differently.

Field.clean(value)

Validates the given value and returns its “cleaned” value as an appropriate Python object.

Raises ValidationError for any errors.

Field.creation_counter = 31
Field.default_error_messages = {u'required': <django.utils.functional.__proxy__ object at 0x3cf0950>}
Field.default_validators = []
Field.empty_values = [None, u'', [], (), {}]
Field.hidden_widget

alias of HiddenInput

Field.prepare_value(value)
Field.run_validators(value)
Field.to_python(value)
Field.validate(value)
Field.widget

alias of TextInput

Field.widget_attrs(widget)

Given a Widget instance (not a Widget class), returns a dictionary of any HTML attributes that should be added to the Widget, based on this Field.

class horizon.forms.CharField(max_length=None, min_length=None, *args, **kwargs)

Bases: django.forms.fields.Field

CharField.to_python(value)

Returns a Unicode object.

CharField.widget_attrs(widget)
class horizon.forms.IntegerField(max_value=None, min_value=None, *args, **kwargs)

Bases: django.forms.fields.Field

IntegerField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3cf0a90>}
IntegerField.to_python(value)

Validates that int() can be called on the input. Returns the result of int(). Returns None for empty values.

IntegerField.widget

alias of NumberInput

IntegerField.widget_attrs(widget)
class horizon.forms.DateField(input_formats=None, *args, **kwargs)

Bases: django.forms.fields.BaseTemporalField

DateField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d2be10>}
DateField.input_formats = <django.utils.functional.__proxy__ object at 0x3d2bdd0>
DateField.strptime(value, format)
DateField.to_python(value)

Validates that the input can be converted to a date. Returns a Python datetime.date object.

DateField.widget

alias of DateInput

class horizon.forms.TimeField(input_formats=None, *args, **kwargs)

Bases: django.forms.fields.BaseTemporalField

TimeField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d2bf90>}
TimeField.input_formats = <django.utils.functional.__proxy__ object at 0x3d2bf10>
TimeField.strptime(value, format)
TimeField.to_python(value)

Validates that the input can be converted to a time. Returns a Python datetime.time object.

TimeField.widget

alias of TimeInput

class horizon.forms.DateTimeField(input_formats=None, *args, **kwargs)

Bases: django.forms.fields.BaseTemporalField

DateTimeField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d40110>}
DateTimeField.input_formats = <django.utils.functional.__proxy__ object at 0x3d40090>
DateTimeField.prepare_value(value)
DateTimeField.strptime(value, format)
DateTimeField.to_python(value)

Validates that the input can be converted to a datetime. Returns a Python datetime.datetime object.

DateTimeField.widget

alias of DateTimeInput

class horizon.forms.TimeField(input_formats=None, *args, **kwargs)

Bases: django.forms.fields.BaseTemporalField

TimeField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d2bf90>}
TimeField.input_formats = <django.utils.functional.__proxy__ object at 0x3d2bf10>
TimeField.strptime(value, format)
TimeField.to_python(value)

Validates that the input can be converted to a time. Returns a Python datetime.time object.

TimeField.widget

alias of TimeInput

class horizon.forms.RegexField(regex, max_length=None, min_length=None, error_message=None, *args, **kwargs)

Bases: django.forms.fields.CharField

RegexField.regex
class horizon.forms.EmailField(max_length=None, min_length=None, *args, **kwargs)

Bases: django.forms.fields.CharField

EmailField.clean(value)
EmailField.default_validators = [<django.core.validators.EmailValidator object at 0x3bf7b10>]
EmailField.widget

alias of EmailInput

class horizon.forms.FileField(*args, **kwargs)

Bases: django.forms.fields.Field

FileField.bound_data(data, initial)
FileField.clean(data, initial=None)
FileField.default_error_messages = {u'contradiction': <django.utils.functional.__proxy__ object at 0x3d40790>, u'max_length': <django.utils.functional.__proxy__ object at 0x3d40650>, u'empty': <django.utils.functional.__proxy__ object at 0x3d40350>, u'invalid': <django.utils.functional.__proxy__ object at 0x3d40250>, u'missing': <django.utils.functional.__proxy__ object at 0x3d402d0>}
FileField.to_python(data)
FileField.widget

alias of ClearableFileInput

class horizon.forms.ImageField(*args, **kwargs)

Bases: django.forms.fields.FileField

ImageField.default_error_messages = {u'invalid_image': <django.utils.functional.__proxy__ object at 0x3d40810>}
ImageField.to_python(data)

Checks that the file-upload field data contains a valid image (GIF, JPG, PNG, possibly others – whatever the Python Imaging Library supports).

class horizon.forms.URLField(max_length=None, min_length=None, *args, **kwargs)

Bases: django.forms.fields.CharField

URLField.clean(value)
URLField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d408d0>}
URLField.default_validators = [<django.core.validators.URLValidator object at 0x3d40910>]
URLField.to_python(value)
URLField.widget

alias of URLInput

class horizon.forms.BooleanField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)

Bases: django.forms.fields.Field

BooleanField.to_python(value)

Returns a Python boolean object.

BooleanField.validate(value)
BooleanField.widget

alias of CheckboxInput

class horizon.forms.NullBooleanField(required=True, widget=None, label=None, initial=None, help_text=u'', error_messages=None, show_hidden_initial=False, validators=[], localize=False)

Bases: django.forms.fields.BooleanField

A field whose valid values are None, True and False. Invalid values are cleaned to None.

NullBooleanField.to_python(value)

Explicitly checks for the string ‘True’ and ‘False’, which is what a hidden field will submit for True and False, and for ‘1’ and ‘0’, which is what a RadioField will submit. Unlike the Booleanfield we need to explicitly check for True, because we are not using the bool() function

NullBooleanField.validate(value)
NullBooleanField.widget

alias of NullBooleanSelect

class horizon.forms.ChoiceField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

Bases: django.forms.fields.Field

ChoiceField.choices
ChoiceField.default_error_messages = {u'invalid_choice': <django.utils.functional.__proxy__ object at 0x3d40a50>}
ChoiceField.to_python(value)

Returns a Unicode object.

ChoiceField.valid_value(value)

Check to see if the provided value is a valid choice

ChoiceField.validate(value)

Validates that the input is in self.choices.

ChoiceField.widget

alias of Select

class horizon.forms.MultipleChoiceField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

Bases: django.forms.fields.ChoiceField

MultipleChoiceField.default_error_messages = {u'invalid_list': <django.utils.functional.__proxy__ object at 0x3d40bd0>, u'invalid_choice': <django.utils.functional.__proxy__ object at 0x3d40b50>}
MultipleChoiceField.hidden_widget

alias of MultipleHiddenInput

MultipleChoiceField.to_python(value)
MultipleChoiceField.validate(value)

Validates that the input is a list or tuple.

MultipleChoiceField.widget

alias of SelectMultiple

class horizon.forms.ComboField(fields=(), *args, **kwargs)

Bases: django.forms.fields.Field

A Field whose clean() method calls multiple Field clean() methods.

ComboField.clean(value)

Validates the given value against all of self.fields, which is a list of Field instances.

class horizon.forms.MultiValueField(fields=(), *args, **kwargs)

Bases: django.forms.fields.Field

A Field that aggregates the logic of multiple Fields.

Its clean() method takes a “decompressed” list of values, which are then cleaned into a single value according to self.fields. Each value in this list is cleaned by the corresponding field – the first value is cleaned by the first field, the second value is cleaned by the second field, etc. Once all fields are cleaned, the list of clean values is “compressed” into a single value.

Subclasses should not have to implement clean(). Instead, they must implement compress(), which takes a list of valid values and returns a “compressed” version of those values – a single value.

You’ll probably want to use this with MultiWidget.

MultiValueField.clean(value)

Validates every value in the given list. A value is validated against the corresponding Field in self.fields.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).

MultiValueField.compress(data_list)

Returns a single value for the given list of values. The values can be assumed to be valid.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.

MultiValueField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3d40d50>}
MultiValueField.validate(value)
class horizon.forms.FloatField(max_value=None, min_value=None, *args, **kwargs)

Bases: django.forms.fields.IntegerField

FloatField.default_error_messages = {u'invalid': <django.utils.functional.__proxy__ object at 0x3cf0bd0>}
FloatField.to_python(value)

Validates that float() can be called on the input. Returns the result of float(). Returns None for empty values.

FloatField.widget_attrs(widget)
class horizon.forms.DecimalField(max_value=None, min_value=None, max_digits=None, decimal_places=None, *args, **kwargs)

Bases: django.forms.fields.IntegerField

DecimalField.default_error_messages = {u'max_whole_digits': <django.utils.functional.__proxy__ object at 0x3d2bc50>, u'max_digits': <django.utils.functional.__proxy__ object at 0x3d2b5d0>, u'invalid': <django.utils.functional.__proxy__ object at 0x3cf0e90>, u'max_decimal_places': <django.utils.functional.__proxy__ object at 0x3d2b910>}
DecimalField.to_python(value)

Validates that the input is a decimal number. Returns a Decimal instance. Returns None for empty values. Ensures that there are no more than max_digits in the number, and no more than decimal_places digits after the decimal point.

DecimalField.validate(value)
DecimalField.widget_attrs(widget)
class horizon.forms.SplitDateTimeField(input_date_formats=None, input_time_formats=None, *args, **kwargs)

Bases: django.forms.fields.MultiValueField

SplitDateTimeField.compress(data_list)
SplitDateTimeField.default_error_messages = {u'invalid_time': <django.utils.functional.__proxy__ object at 0x3d40f10>, u'invalid_date': <django.utils.functional.__proxy__ object at 0x3d40e90>}
SplitDateTimeField.hidden_widget

alias of SplitHiddenDateTimeWidget

SplitDateTimeField.widget

alias of SplitDateTimeWidget

class horizon.forms.IPAddressField(max_length=None, min_length=None, *args, **kwargs)

Bases: django.forms.fields.CharField

IPAddressField.default_validators = [<django.core.validators.RegexValidator object at 0x3bf7c50>]
IPAddressField.to_python(value)
class horizon.forms.GenericIPAddressField(protocol=u'both', unpack_ipv4=False, *args, **kwargs)

Bases: django.forms.fields.CharField

GenericIPAddressField.to_python(value)
class horizon.forms.FilePathField(path, match=None, recursive=False, allow_files=True, allow_folders=False, required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

Bases: django.forms.fields.ChoiceField

class horizon.forms.SlugField(max_length=None, min_length=None, *args, **kwargs)

Bases: django.forms.fields.CharField

SlugField.clean(value)
SlugField.default_validators = [<django.core.validators.RegexValidator object at 0x3bf7b90>]
class horizon.forms.TypedChoiceField(*args, **kwargs)

Bases: django.forms.fields.ChoiceField

TypedChoiceField.to_python(value)

Validates that the value is in self.choices and can be coerced to the right type.

class horizon.forms.TypedMultipleChoiceField(*args, **kwargs)

Bases: django.forms.fields.MultipleChoiceField

TypedMultipleChoiceField.to_python(value)

Validates that the values are in self.choices and can be coerced to the right type.

TypedMultipleChoiceField.validate(value)
class horizon.forms.Media(media=None, **kwargs)

Bases: object

Media.absolute_path(path, prefix=None)
Media.add_css(data)
Media.add_js(data)
Media.render()
Media.render_css()
Media.render_js()
class horizon.forms.MediaDefiningClass

Bases: type

Metaclass for classes that can have media definitions

class horizon.forms.Widget(attrs=None)

Bases: django.forms.widgets.NewBase

Widget.build_attrs(extra_attrs=None, **kwargs)

Helper function for building an attribute dictionary.

Widget.id_for_label(id_)

Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available.

This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value that corresponds to the first ID in the widget’s tags.

Widget.is_hidden = False
Widget.is_localized = False
Widget.is_required = False
Widget.media
Widget.needs_multipart_form = False
Widget.render(name, value, attrs=None)

Returns this Widget rendered as HTML, as a Unicode string.

The ‘value’ given is not guaranteed to be valid input, so subclass implementations should program defensively.

Widget.subwidgets(name, value, attrs=None, choices=())

Yields all “subwidgets” of this widget. Used only by RadioSelect to allow template access to individual <input type=”radio”> buttons.

Arguments are the same as for render().

Widget.value_from_datadict(data, files, name)

Given a dictionary of data and this widget’s name, returns the value of this widget. Returns None if it’s not provided.

class horizon.forms.TextInput(attrs=None)

Bases: django.forms.widgets.Input

TextInput.input_type = u'text'
TextInput.media
class horizon.forms.PasswordInput(attrs=None, render_value=False)

Bases: django.forms.widgets.TextInput

PasswordInput.input_type = u'password'
PasswordInput.media
PasswordInput.render(name, value, attrs=None)
class horizon.forms.HiddenInput(attrs=None)

Bases: django.forms.widgets.Input

HiddenInput.input_type = u'hidden'
HiddenInput.is_hidden = True
HiddenInput.media
class horizon.forms.MultipleHiddenInput(attrs=None, choices=())

Bases: django.forms.widgets.HiddenInput

A widget that handles <input type=”hidden”> for fields that have a list of values.

MultipleHiddenInput.media
MultipleHiddenInput.render(name, value, attrs=None, choices=())
MultipleHiddenInput.value_from_datadict(data, files, name)
class horizon.forms.ClearableFileInput(attrs=None)

Bases: django.forms.widgets.FileInput

ClearableFileInput.clear_checkbox_id(name)

Given the name of the clear checkbox input, return the HTML id for it.

ClearableFileInput.clear_checkbox_label = <django.utils.functional.__proxy__ object at 0x3d25b10>
ClearableFileInput.clear_checkbox_name(name)

Given the name of the file input, return the name of the clear checkbox input.

ClearableFileInput.initial_text = <django.utils.functional.__proxy__ object at 0x3d25a10>
ClearableFileInput.input_text = <django.utils.functional.__proxy__ object at 0x3d25a90>
ClearableFileInput.media
ClearableFileInput.render(name, value, attrs=None)
ClearableFileInput.template_with_clear = u'%(clear)s <label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label>'
ClearableFileInput.template_with_initial = u'%(initial_text)s: %(initial)s %(clear_template)s<br />%(input_text)s: %(input)s'
ClearableFileInput.url_markup_template = u'<a href="{0}">{1}</a>'
ClearableFileInput.value_from_datadict(data, files, name)
class horizon.forms.FileInput(attrs=None)

Bases: django.forms.widgets.Input

FileInput.input_type = u'file'
FileInput.media
FileInput.needs_multipart_form = True
FileInput.render(name, value, attrs=None)
FileInput.value_from_datadict(data, files, name)

File widgets take data from FILES, not POST

class horizon.forms.DateInput(attrs=None, format=None)

Bases: django.forms.widgets.TextInput

DateInput.media
class horizon.forms.DateTimeInput(attrs=None, format=None)

Bases: django.forms.widgets.TextInput

DateTimeInput.media
class horizon.forms.TimeInput(attrs=None, format=None)

Bases: django.forms.widgets.TextInput

TimeInput.media
class horizon.forms.Textarea(attrs=None)

Bases: django.forms.widgets.Widget

Textarea.media
Textarea.render(name, value, attrs=None)
class horizon.forms.CheckboxInput(attrs=None, check_test=None)

Bases: django.forms.widgets.Widget

CheckboxInput.media
CheckboxInput.render(name, value, attrs=None)
CheckboxInput.value_from_datadict(data, files, name)
class horizon.forms.Select(attrs=None, choices=())

Bases: django.forms.widgets.Widget

Select.allow_multiple_selected = False
Select.media
Select.render(name, value, attrs=None, choices=())
Select.render_option(selected_choices, option_value, option_label)
Select.render_options(choices, selected_choices)
class horizon.forms.NullBooleanSelect(attrs=None)

Bases: django.forms.widgets.Select

A Select Widget intended to be used with NullBooleanField.

NullBooleanSelect.media
NullBooleanSelect.render(name, value, attrs=None, choices=())
NullBooleanSelect.value_from_datadict(data, files, name)
class horizon.forms.SelectMultiple(attrs=None, choices=())

Bases: django.forms.widgets.Select

SelectMultiple.allow_multiple_selected = True
SelectMultiple.media
SelectMultiple.render(name, value, attrs=None, choices=())
SelectMultiple.value_from_datadict(data, files, name)
class horizon.forms.RadioSelect(*args, **kwargs)

Bases: django.forms.widgets.RendererMixin, django.forms.widgets.Select

RadioSelect.media
RadioSelect.renderer

alias of RadioFieldRenderer

class horizon.forms.CheckboxSelectMultiple(*args, **kwargs)

Bases: django.forms.widgets.RendererMixin, django.forms.widgets.SelectMultiple

CheckboxSelectMultiple.media
CheckboxSelectMultiple.renderer

alias of CheckboxFieldRenderer

class horizon.forms.MultiWidget(widgets, attrs=None)

Bases: django.forms.widgets.Widget

A widget that is composed of multiple widgets.

Its render() method is different than other widgets’, because it has to figure out how to split a single value for display in multiple widgets. The value argument can be one of two things:

  • A list.
  • A normal value (e.g., a string) that has been “compressed” from a list of values.

In the second case – i.e., if the value is NOT a list – render() will first “decompress” the value into a list before rendering it. It does so by calling the decompress() method, which MultiWidget subclasses must implement. This method takes a single “compressed” value and returns a list.

When render() does its HTML rendering, each value in the list is rendered with the corresponding widget – the first value is rendered in the first widget, the second value is rendered in the second widget, etc.

Subclasses may implement format_output(), which takes the list of rendered widgets and returns a string of HTML that formats them any way you’d like.

You’ll probably want to use this class with MultiValueField.

MultiWidget.decompress(value)

Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.

MultiWidget.format_output(rendered_widgets)

Given a list of rendered widgets (as strings), returns a Unicode string representing the HTML for the whole lot.

This hook allows you to format the HTML design of the widgets, if needed.

MultiWidget.id_for_label(id_)
MultiWidget.media

Media for a multiwidget is the combination of all media of the subwidgets

MultiWidget.needs_multipart_form
MultiWidget.render(name, value, attrs=None)
MultiWidget.value_from_datadict(data, files, name)
class horizon.forms.SplitDateTimeWidget(attrs=None, date_format=None, time_format=None)

Bases: django.forms.widgets.MultiWidget

A Widget that splits datetime input into two <input type=”text”> boxes.

SplitDateTimeWidget.decompress(value)
SplitDateTimeWidget.media
class horizon.forms.BaseForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=None, empty_permitted=False)

Bases: object

BaseForm.add_initial_prefix(field_name)

Add a ‘initial’ prefix for checking dynamic initial values

BaseForm.add_prefix(field_name)

Returns the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

BaseForm.as_p()

Returns this form rendered as HTML <p>s.

BaseForm.as_table()

Returns this form rendered as HTML <tr>s – excluding the <table></table>.

BaseForm.as_ul()

Returns this form rendered as HTML <li>s – excluding the <ul></ul>.

BaseForm.changed_data
BaseForm.clean()

Hook for doing any extra form-wide cleaning after Field.clean() been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

BaseForm.errors

Returns an ErrorDict for the data provided for the form

BaseForm.full_clean()

Cleans all of self.data and populates self._errors and self.cleaned_data.

BaseForm.has_changed()

Returns True if data differs from initial.

BaseForm.hidden_fields()

Returns a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.

BaseForm.is_multipart()

Returns True if the form needs to be multipart-encoded, i.e. it has FileInput. Otherwise, False.

BaseForm.is_valid()

Returns True if the form has no errors. Otherwise, False. If errors are being ignored, returns False.

BaseForm.media

Provide a description of all media required to render the widgets on this form

BaseForm.non_field_errors()

Returns an ErrorList of errors that aren’t associated with a particular field – i.e., from Form.clean(). Returns an empty ErrorList if there are none.

BaseForm.visible_fields()

Returns a list of BoundField objects that aren’t hidden fields. The opposite of the hidden_fields() method.

class horizon.forms.Form(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=None, empty_permitted=False)

Bases: django.forms.forms.NewBase

A collection of Fields, plus their associated data.

Form.base_fields = {}
Form.media

Previous topic

The horizon.forms.views Module

Next topic

The horizon.tabs.base Module

This Page