forms.BoundField.form

BoundField.form The Form instance this BoundField is bound to.

forms.BoundField.field

BoundField.field The form Field instance from the form class that this BoundField wraps.

forms.BoundField.errors

BoundField.errors A list-like object that is displayed as an HTML <ul class="errorlist"> when printed: >>> data = {'subject': 'hi', 'message': '', 'sender': '', 'cc_myself': ''} >>> f = ContactForm(data, auto_id=False) >>> print(f['message']) <input type="text" name="message" required /> >>> f['message'].errors ['This field is required.'] >>> print(f['message'].errors) <ul class="errorlist"><li>This field is required.</l

forms.BoundField.data

BoundField.data This property returns the data for this BoundField extracted by the widget’s value_from_datadict() method, or None if it wasn’t given: >>> unbound_form = ContactForm() >>> print(unbound_form['subject'].data) None >>> bound_form = ContactForm(data={'subject': 'My Subject'}) >>> print(bound_form['subject'].data) My Subject

forms.BoundField.css_classes()

BoundField.css_classes() [source] When you use Django’s rendering shortcuts, CSS classes are used to indicate required form fields or fields that contain errors. If you’re manually rendering a form, you can access these CSS classes using the css_classes method: >>> f = ContactForm(data={'message': ''}) >>> f['message'].css_classes() 'required' If you want to provide some additional classes in addition to the error and required classes that may be required, you can provide

forms.BoundField.auto_id

BoundField.auto_id The HTML ID attribute for this BoundField. Returns an empty string if Form.auto_id is False.

forms.BoundField.as_widget()

BoundField.as_widget(widget=None, attrs=None, only_initial=False) [source] Renders the field by rendering the passed widget, adding any HTML attributes passed as attrs. If no widget is specified, then the field’s default widget will be used. only_initial is used by Django internals and should not be set explicitly.

forms.BoundField.as_hidden()

BoundField.as_hidden(attrs=None, **kwargs) [source] Returns a string of HTML for representing this as an <input type="hidden">. **kwargs are passed to as_widget(). This method is primarily used internally. You should use a widget instead.

forms.BoundField

class BoundField [source] Used to display HTML or access attributes for a single field of a Form instance. The __str__() (__unicode__ on Python 2) method of this object displays the HTML for this field. To retrieve a single BoundField, use dictionary lookup syntax on your form using the field’s name as the key: >>> form = ContactForm() >>> print(form['subject']) <input id="id_subject" type="text" name="subject" maxlength="100" required /> To retrieve all BoundField o

forms.BooleanField

class BooleanField(**kwargs) [source] Default widget: CheckboxInput Empty value: False Normalizes to: A Python True or False value. Validates that the value is True (e.g. the check box is checked) if the field has required=True. Error message keys: required Note Since all Field subclasses have required=True by default, the validation condition here is important. If you want to include a boolean in your form that can be either True or False (e.g. a checked or unchecked checkbox), you mu