#17664: Smart `if` tag silencing exceptions plus `QuerySet` caching equals buggy
behaviour.
-------------------------------------+-------------------------------------
Reporter: mrmachine | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: SVN
Severity: Normal | Resolution:
Keywords: smart if tag | Triage Stage:
queryset exception silenced | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by mrmachine):
I'm not sure I really follow the inner workings of the smart if tag. But
why would `qs` from `{% if qs %}` still be lazy (not evaluated) when `{%
if not qs %}` is no longer lazy (is evaluated)? I thought the first would
be equivalent to `if qs` in Python, which is `if bool(qs)`? Or is `{% if
qs %}` just testing that the variable exists, and doesn't check the value
of it?
Either way, what do you think about the way `QuerySet` will be an empty
queryset after an exception is raised, even though the query is still
invalid and never executed? Shouldn't `QuerySet` cache the exception (not
an empty result set), or just not cache anything and re-execute the query
when evaluated a second time? This wouldn't fix the `{% if qs %}` / `{% if
not qs %}` disparity, but it would prevent the strange side-effect where
subsequent attempts to access `qs` yield an empty queryset.
--
Ticket URL: <https://code.djangoproject.com/ticket/17664#comment:3>
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.