Basic field classes
Base class for all form fields.
Base field constructor.
Find the full error message for an error key.
This will search in the field’s default and overridden error messages for a message matching key. If no message can be found, raises KeyError. Once the template has been found, it will be formatted using kwargs.
Retrieve the label for this field.
If no label has been specified, attempts to generate one using the field’s assigned name in the form.
This method should not be overridden. Instead, pass a value for the label parameter of __init__().
Retrieve what ID labels for this field should use.
By default, returns base_id unchanged. Fancier implementations could append text to base_id before returning it.
For use with fields that render multiple widgets. In such fields, this method should be overridden to return the ID used for the first widget.
Convert data in an HTTP request to a Python value.
If there is an error converting the data, an instance of genshi_forms.errors.ValidationError will be raised.
Render this field into a Genshi markup stream.
Render this field into a Genshi markup stream, using data from an HTTP request.
This method is used because a user might enter invalid data into the form, but when the form is rendered their data should still be the default values for the fields.
name, and attrs are used as in render(). post and files are used as in clean().
A field whose values are True or False.
When cleaning, this field assumes that False values will not be present in the POST dictionary.
A field that cleans to a Python unicode object.
If this field is not present in the POST data, it will be cleaned to ''.
A field that cleans to an integer object.
Returns the result of int(), or None on empty data.
Like TextField, but for passwords.
By default, renders with an genshi_forms.widgets.InputPassword widget. This blocks existing password data from being rendered.
A field for uploaded files.
By default, renders with an genshi_forms.widgets.InputFile widget. If this field is present in a form, that form’s enctype attribute will be set to multipart/form-data.
Data is cleaned to a valid Django file object.
Field for inputting dates.
Data is cleaned to an instance of datetime.date. Any format supported by genshi_forms.parsers.date() is supported by this field. When rendered, it will set class="date" on its widget.
Field for inputting times.
Data is cleaned to an instance of datetime.time. Any format supported by genshi_forms.parsers.time is supported by this field. When rendered, it will set class="time" on its widget.
A field for choosing between a series of key-value options.
When comparing, keys are normalized to strings using unicode().
Cleans data to a (key, value) tuple.
Like ChoiceField, but for more than one choice.
Data is cleaned to a list of (key, value) tuples.
A field that contains multiple sub-fields
Instead of overriding Field.clean() and Field.render(), subclasses may implement the compress() and decompress() methods.
Subclasses must implement the format_output() method.
Convert a list of cleaned values into a single value.
cleaned is a list of values from the Field.clean() methods of each subfield, in order. The return value may be of any type appropriate for the field.
By default, returns cleaned unchanged.
Convert a compressed value into a list of values.
The returned list may be shorter than the list of subfields, in which case it will be padded with None.
Generate a Genshi markup stream.
rendered_fields is a list of markup streams from subfields. name and attrs are as in Field.render().
Field for inputting combined date/times.
Data is cleaned to an instance of datetime.datetime. Any formats supported by genshi_forms.parsers.date() and genshi_forms.parsers.time() are supported. Values are returned in the UTC timezone. If the input should be assumed to use a different timezone, one may be passed to the constructor. By default, all times are assumed to be in UTC.
Field for inputting e-mail addresses.
This field performs only basic validation, that there is a single @ sign in the text.