diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f2a271edd4..9cb19d1015 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ Changelog 2.5 (xx.xx.xxxx) - IN DEVELOPMENT ~~~~~~~~~~~~~~~~ + * Added more informative error message when `|richtext` filter is applied to a non-string value (mukesh5) * Fix: Set `SERVER_PORT` to 443 in `Page.dummy_request()` for HTTPS sites (Sergey Fedoseev) * Fix: Validation error messages in `InlinePanel` no longer count towards `max_num` when disabling the 'add' button (Todd Dembrey, Thibaud Colas) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 7882c8d3b2..b2c6228a0f 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -337,6 +337,7 @@ Contributors * Nick Travis * Maylon Pedroso * Thijs Walcarius +* mukesh5 Translators =========== diff --git a/docs/releases/2.5.rst b/docs/releases/2.5.rst index 9363d129f2..1cda5d3b5c 100644 --- a/docs/releases/2.5.rst +++ b/docs/releases/2.5.rst @@ -14,6 +14,8 @@ What's new Other features ~~~~~~~~~~~~~~ + * Added more informative error message when ``|richtext`` filter is applied to a non-string value (mukesh5) + Bug fixes ~~~~~~~~~ diff --git a/wagtail/core/templatetags/wagtailcore_tags.py b/wagtail/core/templatetags/wagtailcore_tags.py index b14de2345b..dda1cf62d8 100644 --- a/wagtail/core/templatetags/wagtailcore_tags.py +++ b/wagtail/core/templatetags/wagtailcore_tags.py @@ -87,7 +87,10 @@ def richtext(value): elif value is None: html = '' else: - html = expand_db_html(value) + if isinstance(value, str): + html = expand_db_html(value) + else: + raise TypeError("'richtext' template filter received an invalid value; expected string, got {}.".format(type(value))) return mark_safe('