mirror of
https://github.com/django/django.git
synced 2025-03-31 19:46:42 +00:00
Fixed #29617 -- Fixed Template crash if template_string is lazy.
Regression in 3a148f958dddd97c1379081118c30fbede6b6bc4.
This commit is contained in:
parent
4198445afc
commit
9f3b9ffd51
@ -152,7 +152,7 @@ class Template:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.origin = origin
|
self.origin = origin
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
self.source = template_string
|
self.source = str(template_string) # May be lazy.
|
||||||
self.nodelist = self.compile_nodelist()
|
self.nodelist = self.compile_nodelist()
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
@ -11,3 +11,6 @@ Bugfixes
|
|||||||
|
|
||||||
* Fixed a regression in Django 2.0.7 that broke the ``regex`` lookup on MariaDB
|
* Fixed a regression in Django 2.0.7 that broke the ``regex`` lookup on MariaDB
|
||||||
(even though MariaDB isn't officially supported) (:ticket:`29544`).
|
(even though MariaDB isn't officially supported) (:ticket:`29544`).
|
||||||
|
|
||||||
|
* Fixed a regression where ``django.template.Template`` crashed if the
|
||||||
|
``template_string`` argument is lazy (:ticket:`29617`).
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
from django.template.base import Variable, VariableDoesNotExist
|
from django.template import Context, Template, Variable, VariableDoesNotExist
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
|
from django.utils.translation import gettext_lazy
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateTests(SimpleTestCase):
|
||||||
|
def test_lazy_template_string(self):
|
||||||
|
template_string = gettext_lazy('lazy string')
|
||||||
|
self.assertEqual(Template(template_string).render(Context()), template_string)
|
||||||
|
|
||||||
|
|
||||||
class VariableDoesNotExistTests(SimpleTestCase):
|
class VariableDoesNotExistTests(SimpleTestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user