Ticket #17229: 17229.2.patch
File 17229.2.patch, 4.3 KB (added by , 13 years ago) |
---|
-
docs/topics/i18n/timezones.txt
307 307 Server time: {{ value }} 308 308 {% endtimezone %} 309 309 310 .. note::311 312 In the second block, ``None`` resolves to the Python object ``None``313 because it isn't defined in the template context, not because it's the314 string ``None``.315 316 310 .. templatetag:: get_current_timezone 317 311 318 312 get_current_timezone -
docs/releases/1.5.txt
33 33 What's new in Django 1.5 34 34 ======================== 35 35 36 Minor features 37 ~~~~~~~~~~~~~~ 38 39 Django 1.5 also includes several smaller improvements worth noting: 40 41 * The template engine now interprets ``True``, ``False`` and ``None`` as the 42 corresponding Python objects. 43 36 44 Backwards incompatible changes in 1.5 37 45 ===================================== 38 46 -
docs/ref/templates/api.txt
111 111 >>> t.render(c) 112 112 "My name is Dolores." 113 113 114 Variables and lookups 115 ~~~~~~~~~~~~~~~~~~~~~ 116 114 117 Variable names must consist of any letter (A-Z), any digit (0-9), an underscore 115 118 (but they must not start with an underscore) or a dot. 116 119 … … 225 228 if your variable is not callable (allowing you to access attributes of 226 229 the callable, for example). 227 230 228 229 231 .. _invalid-template-variables: 230 232 231 233 How invalid variables are handled … … 263 265 in order to debug a specific template problem, then cleared 264 266 once debugging is complete. 265 267 268 Builtin variables 269 ~~~~~~~~~~~~~~~~~ 270 271 Every context contains ``True``, ``False`` and ``None``. As you would expect, 272 these variables resolve to the corresponding Python objects. 273 274 .. versionadded:: 1.5 275 Before Django 1.5, these variables weren't a special case, and they 276 resolved to ``None`` unless you defined them in the context. 277 266 278 Playing with Context objects 267 279 ---------------------------- 268 280 -
tests/regressiontests/templates/tests.py
372 372 with self.assertRaises(urlresolvers.NoReverseMatch): 373 373 t.render(c) 374 374 375 376 @override_settings(DEBUG=True, TEMPLATE_DEBUG = True) 375 @override_settings(DEBUG=True, TEMPLATE_DEBUG=True) 377 376 def test_no_wrapped_exception(self): 378 377 """ 379 378 The template system doesn't wrap exceptions, but annotates them. 380 379 Refs #16770 381 382 380 """ 383 381 c = Context({"coconuts": lambda: 42 / 0}) 384 382 t = Template("{{ coconuts }}") … … 387 385 388 386 self.assertEqual(cm.exception.django_template_source[1], (0, 14)) 389 387 390 391 388 def test_invalid_block_suggestion(self): 392 389 # See #7876 393 390 from django.template import Template, TemplateSyntaxError … … 610 607 # Call methods returned from dictionary lookups 611 608 'basic-syntax38': ('{{ var.callable }}', {"var": {"callable": lambda: "foo bar"}}, "foo bar"), 612 609 610 'builtins01': ('{{ True }}', {}, "True"), 611 'builtins02': ('{{ False }}', {}, "False"), 612 'builtins03': ('{{ None }}', {}, "None"), 613 613 614 # List-index syntax allows a template to access a certain item of a subscriptable object. 614 615 'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"), 615 616 -
django/template/context.py
18 18 self._reset_dicts(dict_) 19 19 20 20 def _reset_dicts(self, value=None): 21 self.dicts = [value or {}] 21 builtins = {'True': True, 'False': False, 'None': None} 22 if value: 23 builtins.update(value) 24 self.dicts = [builtins] 22 25 23 26 def __copy__(self): 24 27 duplicate = copy(super(BaseContext, self))