| 96 | bound_field_class = None |
| 97 | |
| 98 | def __init__( |
| 99 | self, |
| 100 | *, |
| 101 | required=True, |
| 102 | widget=None, |
| 103 | label=None, |
| 104 | initial=None, |
| 105 | help_text="", |
| 106 | error_messages=None, |
| 107 | show_hidden_initial=False, |
| 108 | validators=(), |
| 109 | localize=False, |
| 110 | disabled=False, |
| 111 | label_suffix=None, |
| 112 | template_name=None, |
| 113 | bound_field_class=None, |
| 114 | ): |
| 115 | # required -- Boolean that specifies whether the field is required. |
| 116 | # True by default. |
| 117 | # widget -- A Widget class, or instance of a Widget class, that should |
| 118 | # be used for this Field when displaying it. Each Field has a |
| 119 | # default Widget that it'll use if you don't specify this. In |
| 120 | # most cases, the default widget is TextInput. |
| 121 | # label -- A verbose name for this field, for use in displaying this |
| 122 | # field in a form. By default, Django will use a "pretty" |
| 123 | # version of the form field name, if the Field is part of a |
| 124 | # Form. |
| 125 | # initial -- A value to use in this Field's initial display. This value |
| 126 | # is *not* used as a fallback if data isn't given. |
| 127 | # help_text -- An optional string to use as "help text" for this Field. |
| 128 | # error_messages -- An optional dictionary to override the default |
| 129 | # messages that the field will raise. |
| 130 | # show_hidden_initial -- Boolean that specifies if it is needed to |
| 131 | # render a hidden widget with initial value |
| 132 | # after widget. |
| 133 | # validators -- List of additional validators to use |
| 134 | # localize -- Boolean that specifies if the field should be localized. |
| 135 | # disabled -- Boolean that specifies whether the field is disabled, |
| 136 | # that is its widget is shown in the form but not editable. |
| 137 | # label_suffix -- Suffix to be added to the label. Overrides |
| 138 | # form's label_suffix. |
| 139 | # bound_field_class -- BoundField class to use in |
| 140 | # Field.get_bound_field. |
| 141 | self.required, self.label, self.initial = required, label, initial |
| 142 | self.show_hidden_initial = show_hidden_initial |
| 143 | self.help_text = help_text |
| 144 | self.disabled = disabled |
| 145 | self.label_suffix = label_suffix |
| 146 | self.bound_field_class = bound_field_class or self.bound_field_class |
| 147 | widget = widget or self.widget |
| 148 | if isinstance(widget, type): |
| 149 | widget = widget() |
| 150 | else: |
| 151 | widget = copy.deepcopy(widget) |
| 152 | |
| 153 | # Trigger the localization machinery if needed. |
| 154 | self.localize = localize |
| 155 | if self.localize: |