Ticket #17229: 17229.2.patch

File 17229.2.patch, 4.3 KB (added by aaugustin, 3 years ago)
  • docs/topics/i18n/timezones.txt

     
    307307        Server time: {{ value }}
    308308    {% endtimezone %}
    309309
    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 the
    314     string ``None``.
    315 
    316310.. templatetag:: get_current_timezone
    317311
    318312get_current_timezone
  • docs/releases/1.5.txt

     
    3333What's new in Django 1.5
    3434========================
    3535
     36Minor features
     37~~~~~~~~~~~~~~
     38
     39Django 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
    3644Backwards incompatible changes in 1.5
    3745=====================================
    3846
  • docs/ref/templates/api.txt

     
    111111    >>> t.render(c)
    112112    "My name is Dolores."
    113113
     114Variables and lookups
     115~~~~~~~~~~~~~~~~~~~~~
     116
    114117Variable names must consist of any letter (A-Z), any digit (0-9), an underscore
    115118(but they must not start with an underscore) or a dot.
    116119
     
    225228     if your variable is not callable (allowing you to access attributes of
    226229     the callable, for example).
    227230
    228 
    229231.. _invalid-template-variables:
    230232
    231233How invalid variables are handled
     
    263265    in order to debug a specific template problem, then cleared
    264266    once debugging is complete.
    265267
     268Builtin variables
     269~~~~~~~~~~~~~~~~~
     270
     271Every context contains ``True``, ``False`` and ``None``. As you would expect,
     272these 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
    266278Playing with Context objects
    267279----------------------------
    268280
  • tests/regressiontests/templates/tests.py

     
    372372        with self.assertRaises(urlresolvers.NoReverseMatch):
    373373            t.render(c)
    374374
    375 
    376     @override_settings(DEBUG=True, TEMPLATE_DEBUG = True)
     375    @override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
    377376    def test_no_wrapped_exception(self):
    378377        """
    379378        The template system doesn't wrap exceptions, but annotates them.
    380379        Refs #16770
    381 
    382380        """
    383381        c = Context({"coconuts": lambda: 42 / 0})
    384382        t = Template("{{ coconuts }}")
     
    387385
    388386        self.assertEqual(cm.exception.django_template_source[1], (0, 14))
    389387
    390 
    391388    def test_invalid_block_suggestion(self):
    392389        # See #7876
    393390        from django.template import Template, TemplateSyntaxError
     
    610607            # Call methods returned from dictionary lookups
    611608            'basic-syntax38': ('{{ var.callable }}', {"var": {"callable": lambda: "foo bar"}}, "foo bar"),
    612609
     610            'builtins01': ('{{ True }}', {}, "True"),
     611            'builtins02': ('{{ False }}', {}, "False"),
     612            'builtins03': ('{{ None }}', {}, "None"),
     613
    613614            # List-index syntax allows a template to access a certain item of a subscriptable object.
    614615            'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),
    615616
  • django/template/context.py

     
    1818        self._reset_dicts(dict_)
    1919
    2020    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]
    2225
    2326    def __copy__(self):
    2427        duplicate = copy(super(BaseContext, self))
Back to Top