From 9ae623396509b06da850563abd4fa407cebda754 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 30 Jan 2025 08:52:38 +0100 Subject: [PATCH] Wrap 2 more BASE_URL usages with str() In 59372aba3381 a lazily evaluated BASE_URL tool was introduced. I found 2 more cases in which BASE_URL was not "collapsed into a string" magically by `__add__`, one of which actually causing an `Object of type TenantBaseURL is not JSON serializable` --- bugsink/debug_views.py | 2 +- ingest/models.py | 2 +- phonehome/tasks.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bugsink/debug_views.py b/bugsink/debug_views.py index fa15284..4f6b567 100644 --- a/bugsink/debug_views.py +++ b/bugsink/debug_views.py @@ -203,7 +203,7 @@ def csrf_debug(request): # We do this here, and not in urls.py, because urls.py cannot be changed on-demand in tests raise Http404("This view is only available in DEBUG_CSRF mode.") - context = {"relevant_settings": {"BASE_URL": get_settings().BASE_URL}} + context = {"relevant_settings": {"BASE_URL": str(get_settings().BASE_URL)}} context["relevant_settings"].update({k: getattr(settings, k) for k in [ "ALLOWED_HOSTS", "SECURE_PROXY_SSL_HEADER", diff --git a/ingest/models.py b/ingest/models.py index 7fcf634..6d8ed80 100644 --- a/ingest/models.py +++ b/ingest/models.py @@ -48,7 +48,7 @@ class StoreEnvelope: # arguably "debug", but if you turned StoreEnvelope on, you probably want to use its results "soon", and I'd # rather not have another thing for people to configure. - logger.info("envelope stored, available at %s%s", get_settings().BASE_URL, envelope.get_absolute_url()) + logger.info("envelope stored, available at %s%s", str(get_settings().BASE_URL), envelope.get_absolute_url()) class DontStoreEnvelope: diff --git a/phonehome/tasks.py b/phonehome/tasks.py index 336cc46..88ba624 100644 --- a/phonehome/tasks.py +++ b/phonehome/tasks.py @@ -75,7 +75,7 @@ def _make_message_body(): "settings": { # Settings that tell us "who you are", and are relevant in the context of licensing. - "BASE_URL": get_settings().BASE_URL, + "BASE_URL": str(get_settings().BASE_URL), "SITE_TITLE": get_settings().SITE_TITLE, "DEFAULT_FROM_EMAIL": settings.DEFAULT_FROM_EMAIL,