forms.Widget.format_value()

format_value(value) Cleans and returns a value for use in the widget template. value isn’t guaranteed to be valid input, therefore subclass implementations should program defensively. Changed in Django 1.10: In older versions, this method is a private API named _format_value(). The old name will work until Django 2.0.

forms.Widget.id_for_label()

id_for_label(self, id_) [source] Returns the HTML ID attribute of this widget for use by a <label>, given the ID of the field. Returns None if an ID isn’t 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.

forms.Widget

class Widget(attrs=None) [source] This abstract class cannot be rendered, but provides the basic attribute attrs. You may also implement or override the render() method on custom widgets. attrs A dictionary containing HTML attributes to be set on the rendered widget. >>> from django import forms >>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',}) >>> name.render('name', 'A name') '<input title="Your name" type="text" name="name" value="A nam

forms.URLField

class URLField(**kwargs) [source] Default widget: URLInput Empty value: '' (an empty string) Normalizes to: A Unicode object. Validates that the given value is a valid URL. Error message keys: required, invalid Takes the following optional arguments: max_length min_length These are the same as CharField.max_length and CharField.min_length.

forms.URLField.min_length

min_length These are the same as CharField.max_length and CharField.min_length.

forms.URLField.max_length

max_length

forms.URLInput

class URLInput [source] Text input: <input type="url" ...>

forms.TimeInput

class TimeInput [source] Time input as a simple text box: <input type='text' ...> Takes same arguments as TextInput, with one more optional argument: format The format in which this field’s initial value will be displayed. If no format argument is provided, the default format is the first format found in TIME_INPUT_FORMATS and respects Format localization. For the treatment of microseconds, see DateTimeInput.

forms.TypedChoiceField

class TypedChoiceField(**kwargs) [source] Just like a ChoiceField, except TypedChoiceField takes two extra arguments, coerce and empty_value. Default widget: Select Empty value: Whatever you’ve given as empty_value. Normalizes to: A value of the type provided by the coerce argument. Validates that the given value exists in the list of choices and can be coerced. Error message keys: required, invalid_choice Takes extra arguments: coerce A function that takes one argument and returns a

forms.TypedMultipleChoiceField

class TypedMultipleChoiceField(**kwargs) [source] Just like a MultipleChoiceField, except TypedMultipleChoiceField takes two extra arguments, coerce and empty_value. Default widget: SelectMultiple Empty value: Whatever you’ve given as empty_value Normalizes to: A list of values of the type provided by the coerce argument. Validates that the given values exists in the list of choices and can be coerced. Error message keys: required, invalid_choice The invalid_choice error message may con