#22767: Unexpected value for an unset variable with length filter in templates
---------------------------------+--------------------
     Reporter:  Walkman          |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Template system  |    Version:  1.6
     Severity:  Normal           |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+--------------------
 Not sure if this is a bug or I'm just missing something, but I expected
 this to be `False` anyway:
 `{% if groups|length > 0 %}`

 This will be `True` in Django 1.6.5 if `groups` is an unset variable. The
 `TEMPLATE_STRING_IF_INVALID` setting has the default value (empty string).

 I know it's not idiomatic code and I fixed it:
 `{% if groups %}`
 (which works as expected), but other newbies like me can have a hard time
 figuring out what's wrong.

 I checked `{% if None|length > 0 %}` and it is also `True`, which is
 clearly not expected.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22767>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.d07030fd1967ea94d6df97fc5d65102a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to