=== modified file 'django/forms/forms.py'
|
|
|
70 | 70 | # class, not to the Form class. |
71 | 71 | def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, |
72 | 72 | initial=None, error_class=ErrorList, label_suffix=':', |
| 73 | label_template='<label for="%(id)s"%(attrs)s>%(contents)s</label>', |
73 | 74 | empty_permitted=False): |
74 | 75 | self.is_bound = data is not None or files is not None |
75 | 76 | self.data = data or {} |
… |
… |
|
79 | 80 | self.initial = initial or {} |
80 | 81 | self.error_class = error_class |
81 | 82 | self.label_suffix = label_suffix |
| 83 | self.label_template = label_template |
82 | 84 | self.empty_permitted = empty_permitted |
83 | 85 | self._errors = None # Stores the errors after clean() has been called. |
84 | 86 | self._changed_data = None |
… |
… |
|
374 | 376 | id_ = widget.attrs.get('id') or self.auto_id |
375 | 377 | if id_: |
376 | 378 | attrs = attrs and flatatt(attrs) or '' |
377 | | contents = u'<label for="%s"%s>%s</label>' % (widget.id_for_label(id_), attrs, unicode(contents)) |
| 379 | contents = self.form.label_template % { |
| 380 | 'id': widget.id_for_label(id_), |
| 381 | 'attrs': attrs, |
| 382 | 'contents': unicode(contents) |
| 383 | } |
378 | 384 | return mark_safe(contents) |
379 | 385 | |
380 | 386 | def _is_hidden(self): |
=== modified file 'django/forms/models.py'
|
|
|
186 | 186 | class BaseModelForm(BaseForm): |
187 | 187 | def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, |
188 | 188 | initial=None, error_class=ErrorList, label_suffix=':', |
| 189 | label_template='<label for="%(id)s"%(attrs)s>%(contents)s</label>', |
189 | 190 | empty_permitted=False, instance=None): |
190 | 191 | opts = self._meta |
191 | 192 | if instance is None: |
… |
… |
|
199 | 200 | if initial is not None: |
200 | 201 | object_data.update(initial) |
201 | 202 | super(BaseModelForm, self).__init__(data, files, auto_id, prefix, object_data, |
202 | | error_class, label_suffix, empty_permitted) |
| 203 | error_class, label_suffix, label_template, empty_permitted) |
203 | 204 | def clean(self): |
204 | 205 | self.validate_unique() |
205 | 206 | |