#17229: Allow 'True', 'False' and 'None' to resolve to corresponding Python 
objects
-------------------------------------+-------------------------------------
     Reporter:  anatoly techtonik    |                    Owner:  nobody
  <techtonik@…>                      |                   Status:  reopened
         Type:  New feature          |                  Version:  1.2
    Component:  Template system      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Design
     Keywords:                       |  decision needed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by anatoly techtonik <techtonik@…>):

 Replying to [comment:5 lukeplant]:
 > Your initial example only did a comparison to `True`, and didn't mention
 any comparison to `None`. I am not a mind reader!

 I couldn't understand the magic behavior and where the bug is, because
 documentation doesn't warn that you can't use Python True/False literals
 in expressions that look like usual Python expressions (I also could not
 understand why would anyone limit people from using them). So, as a result
 of this report I expected the way to compare booleans to be
 
[https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#operator
 at least documented] if not fixed, because after spending several hours
 trying to debug this stuff, you start to understand people sending rays of
 hate to Django templating system. :)

 My frustration with the fact that I don't understand how to compare
 booleans (when you can compare integers) is the reason I selected UI/UX
 checkbox several times. When I understood that it is not the boolean story
 alone, I split the user story into two. This one about True/False alone,
 and #17230 for `None` bug.

 > I can see why this would be useful, but I'm not entirely convinced,
 given that we've survived without these for a long time. Therefore marking
 DDN.

 I anticipated such reaction when it became clear in #17230 that the bug is
 actually there and was there for a long time, so thanks for not closing it
 immediately as 'works for me'.

 [http://codereview.appspot.com/5373080/diff2/3:7002/templates/all.html My
 workaround] (which I feel is still hackish and not really intuitive) is:
 {{{
   {%if closed|lower == 'false' %} (opened only) {%endif%}
   {%if closed|lower == 'true' %} (closed only) {%endif%}
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17229#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to