diff options
| author | Moritz Sichert <moritz.sichert@googlemail.com> | 2015-03-10 21:21:28 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-03-18 09:11:44 -0400 |
| commit | 571e093a258b00b25c24481af7acf0d0a034ec8c (patch) | |
| tree | cc7a23f375ac4429086a7f0b5dec6456dd1a84c3 /django/forms | |
| parent | 1cd2584c980ca547ba34d7b0f9d2dc89569803fb (diff) | |
[1.8.x] Refs #24469 -- Fixed escaping of forms, fields, and media in non-Django templates.
Backport of 6bff3439894ac22d80f270f36513fc86586273f3 from master
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/forms.py | 6 | ||||
| -rw-r--r-- | django/forms/widgets.py | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index 16fc5b00f2..869cc83283 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -138,6 +138,9 @@ class BaseForm(object): self.fields = copy.deepcopy(self.base_fields) self._bound_fields_cache = {} + def __html__(self): + return force_text(self) + def __str__(self): return self.as_table() @@ -534,6 +537,9 @@ class BoundField(object): self.help_text = field.help_text or '' self._initial_value = UNSET + def __html__(self): + return force_text(self) + def __str__(self): """Renders this field as an HTML widget.""" if self.field.show_hidden_initial: diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 0ed7613d0f..811852bb0b 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -44,6 +44,9 @@ class Media(object): for name in MEDIA_TYPES: getattr(self, 'add_' + name)(media_attrs.get(name, None)) + def __html__(self): + return force_text(self) + def __str__(self): return self.render() |
