[Django] #26479: Add "is not" comparison to the if template tag

13 views
Skip to first unread message

Django

unread,
Apr 8, 2016, 5:32:33 AM4/8/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+--------------------
Reporter: alasdairnicol | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
#26118 added the is comparison to the if template tag. We should add the
is not comparison as well.

From a quick test, it seems that `{% x is not None %}` is currently
evaluated as `x is (not None)`, instead of `x is not None`.

Discussion on django-developers mailing list:
https://groups.google.com/d/msg/django-developers/jYdYCAtHHdw/WJYNXqAzEwAJ

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

Django

unread,
Apr 8, 2016, 5:32:40 AM4/8/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by alasdairnicol):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => alasdairnicol
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:1>

Django

unread,
Apr 8, 2016, 7:18:44 AM4/8/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:2>

Django

unread,
Apr 9, 2016, 8:50:08 AM4/9/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by alasdairnicol):

* has_patch: 0 => 1


Comment:

Pull request https://github.com/django/django/pull/6436/files

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:3>

Django

unread,
Apr 9, 2016, 1:01:49 PM4/9/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c16b9dd8e0ae757616e9accbaffecc521191ee98" c16b9dd]:
{{{
#!CommitTicketReference repository=""
revision="c16b9dd8e0ae757616e9accbaffecc521191ee98"
Fixed #26479 -- Added 'is not' operator to the if tag.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:4>

Django

unread,
Apr 11, 2016, 10:50:55 AM4/11/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by alasdairnicol):

* status: closed => new
* resolution: fixed =>


Comment:

Re-opening because I think we should we document (and add tests) for when
either or both of the variables are not in the template context.

As an aside, I can't see any tests for the != operator in the
[https://github.com/django/django/blob/c16b9dd8e0ae757616e9accbaffecc521191ee98/tests/template_tests/syntax_tests/test_if.py
test_if.py]. If I haven't overlooked them and they are missing, we could
open a separate ticket to add them.

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:5>

Django

unread,
Apr 11, 2016, 11:51:51 AM4/11/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by timgraham):

* has_patch: 1 => 0


Comment:

#17664 "{% if %} template tag silences exceptions inconsistently" and a
couple related tickets might be relevant to that.

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:6>

Django

unread,
Apr 28, 2016, 6:42:19 PM4/28/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by alasdairnicol):

* has_patch: 0 => 1


Comment:

New pull request: https://github.com/django/django/pull/6532

I had a quick look at #17664, but I wasn't sure what I should do for this
ticket. If more changes/test cases related to unhandled exceptions are
required, I think somebody else will have to take over the ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:7>

Django

unread,
Apr 29, 2016, 12:40:00 PM4/29/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"dac075e9103ba961af4f70b4011616daa72985d4" dac075e]:
{{{
#!CommitTicketReference repository=""
revision="dac075e9103ba961af4f70b4011616daa72985d4"
Refs #26479 -- Documented is/is not if tag operator behavior for
nonexistent variables.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:8>

Django

unread,
Apr 29, 2016, 12:40:43 PM4/29/16
to django-...@googlegroups.com
#26479: Add "is not" comparison to the if template tag
---------------------------------+-----------------------------------------
Reporter: alasdairnicol | Owner: alasdairnicol
Type: New feature | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/26479#comment:9>

Reply all
Reply to author
Forward
0 new messages