diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 1a4e1eda10..18f1b9ab30 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -344,6 +344,8 @@ def cycle(parser, token):
elif len(args) == 2:
name = args[1]
+ if not hasattr(parser, '_namedCycleNodes'):
+ raise TemplateSyntaxError("No named cycles in template: '%s' is not defined" % name)
if not parser._namedCycleNodes.has_key(name):
raise TemplateSyntaxError("Named cycle '%s' does not exist" % name)
return parser._namedCycleNodes[name]
diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py
index 122c1ed965..48da3441f3 100644
--- a/tests/othertests/templates.py
+++ b/tests/othertests/templates.py
@@ -317,8 +317,8 @@ TEMPLATE_TESTS = {
### I18N ##################################################################
# {% spaceless %} tag
- 'spaceless01': ("{% spaceless %} text {% endspaceless %}", {}, " text "),
- 'spaceless02': ("{% spaceless %} \n text \n {% endspaceless %}", {}, " text "),
+ 'spaceless01': ("{% spaceless %} text {% endspaceless %}", {}, " text "),
+ 'spaceless02': ("{% spaceless %} \n text \n {% endspaceless %}", {}, " text "),
'spaceless03': ("{% spaceless %}text{% endspaceless %}", {}, "text"),
# simple translation of a string delimited by '