Fix check for lazily evaluated page_description

_delegated_text no longer exists in Django as of ee36e101e8

This is also how Django internally checks for lazily-translated strings (search for Promise in its codebase)
pull/10550/head
Sage Abdullah 2023-06-09 16:01:15 +01:00 zatwierdzone przez Matt Westcott
rodzic 1b71ab8f7c
commit 52877cad10
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -42,7 +42,7 @@ from django.utils import timezone
from django.utils import translation as translation
from django.utils.cache import patch_cache_control
from django.utils.encoding import force_str
from django.utils.functional import cached_property
from django.utils.functional import cached_property, Promise
from django.utils.module_loading import import_string
from django.utils.text import capfirst, slugify
from django.utils.translation import gettext_lazy as _
@ -2231,7 +2231,7 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
# make sure that page_description is actually a string rather than a model field
if isinstance(description, str):
return description
elif getattr(description, "_delegate_text", None):
elif isinstance(description, Promise):
# description is a lazy object (e.g. the result of gettext_lazy())
return str(description)
else: