diff --git a/django/template/base.py b/django/template/base.py
index dc6b0c3..ba2694b 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -690,7 +690,9 @@ class Variable(object):
         self.lookups = None
         self.translate = False
         self.message_context = None
-
+        if not isinstance(var, six.string_types):
+            raise TypeError(
+                "Variable must be a string or number, got %s" % type(var))
         try:
             # First try to treat this variable as a number.
             #
diff --git a/tests/template_tests/test_parser.py b/tests/template_tests/test_parser.py
index 9422da8..60454df 100644
--- a/tests/template_tests/test_parser.py
+++ b/tests/template_tests/test_parser.py
@@ -86,6 +86,11 @@ class ParserTests(TestCase):
             Variable, "article._hidden"
         )
 
+        # Variables should raise on non string type
+        self.assertRaises(TypeError,
+            Variable, {}
+        )
+
     @override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
     def test_compile_filter_error(self):
         # regression test for #19819
