diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 9c7d941126..1101c20003 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -292,7 +292,7 @@ class IfNode(Node): @property def nodelist(self): - return NodeList(node for _, nodelist in self.conditions_nodelists for node in nodelist) + return NodeList(iter(self)) def render(self, context): for condition, nodelist in self.conditions_nodelists: