diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 9c7d941126e..1101c200031 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: