diff --git a/django/template/__init__.py b/django/template/__init__.py index 4f06f34e6b..d18bc3758c 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -605,7 +605,13 @@ def resolve_variable(path, context): (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.') """ - if path[0] in ('"', "'") and path[0] == path[-1]: + if path[0] in '0123456789': + number_type = '.' in path and float or int + try: + current = number_type(path) + except ValueError: + current = '' + elif path[0] in ('"', "'") and path[0] == path[-1]: current = path[1:-1] else: current = context