#23913: = comparison does work in templates although it shouldn't
---------------------------------+--------------------
Reporter: googol7 | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
There's no = operator documented:
https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#operator
For comparisons we use the == operator as = does assign values in most
languages. In JavaScript the = assignment for example always returns true
here:
<script language="javascript">
a = 'foo';
b = 'bar';
if (a=b) {
alert('assignment always returns true here')
}
</script>
BUT in the Django templates = does work like a comparison operator:
{% if "a" = "a" %}TRUE but Django should throw an error because there's no
= operator{% endif %}
{% if "a" = "b" %}Django doesn't return True here{% endif %}
I think this is highly misleading and confusing.
--
Ticket URL: <https://code.djangoproject.com/ticket/23913>
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.b9a87fc0cd68db887e1a060f3a510790%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.