Projet

Général

Profil

0001-dj22-decode-response.content-42950.patch

Benjamin Dauvergne, 15 mai 2020 11:35

Télécharger (1,22 ko)

Voir les différences:

Subject: [PATCH] dj22: decode response.content (#42950)

It seems that starting with Django 2.0 bytes are not automatically
decoded when used in templates, as py3 with Django 1.11 does not show
byte strings in login templates.
 src/authentic2/utils/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/authentic2/utils/__init__.py
217 217
        # Force a TemplateResponse to be rendered.
218 218
        if not getattr(response, 'is_rendered', True) and callable(getattr(response, 'render', None)):
219 219
            response = response.render()
220
        content = response.content
220
        content = response.content.decode('utf-8')
221 221
        status_code = response.status_code
222 222
        if hasattr(response, 'context_data') and response.context_data:
223 223
            extra_css_class = response.context_data.get('block-extra-css-class', '')
224
-