From 28c1d5eda3822c2edad8f0559671042029faa17d Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 17 Sep 2021 11:17:30 -0700 Subject: [PATCH] web_framework, tests: Workaround captcha 0.5.6 vs. Django 3.2 Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/tests/data/django_test_settings.py | 6 ++++++ plinth/web_framework.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/plinth/tests/data/django_test_settings.py b/plinth/tests/data/django_test_settings.py index 1d31afca4..1cc2f15a3 100644 --- a/plinth/tests/data/django_test_settings.py +++ b/plinth/tests/data/django_test_settings.py @@ -5,6 +5,12 @@ Django settings for test modules. import os +# Workaround for django-simple-captcha 0.5.6 not being compatible with +# Django 3.2. 0.5.14 is almost there in Debian. Workaround only until then. +import django.utils.encoding + +django.utils.encoding.python_2_unicode_compatible = lambda x: x + TEST_DATA_DIR = os.path.dirname(os.path.abspath(__file__)) AXES_ENABLED = False diff --git a/plinth/web_framework.py b/plinth/web_framework.py index 22689c963..678012688 100644 --- a/plinth/web_framework.py +++ b/plinth/web_framework.py @@ -22,6 +22,10 @@ logger = logging.getLogger(__name__) def init(read_only=False): """Setup Django configuration in the absence of .settings file""" + # Workaround for django-simple-captcha 0.5.6 not being compatible with + # Django 3.2. 0.5.14 is almost there in Debian. Workaround only until then. + django.utils.encoding.python_2_unicode_compatible = lambda x: x + if cfg.secure_proxy_ssl_header: settings.SECURE_PROXY_SSL_HEADER = (cfg.secure_proxy_ssl_header, 'https')