Opened 9 years ago

Closed 9 years ago

#26479 closed New feature (fixed)

Add "is not" comparison to the if template tag

Reported by: Alasdair Nicol Owned by: Alasdair Nicol
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

#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

Change History (9)

comment:1 by Alasdair Nicol, 9 years ago

Owner: changed from nobody to Alasdair Nicol
Status: newassigned

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Alasdair Nicol, 9 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In c16b9dd:

Fixed #26479 -- Added 'is not' operator to the if tag.

comment:5 by Alasdair Nicol, 9 years ago

Resolution: fixed
Status: closednew

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 test_if.py. If I haven't overlooked them and they are missing, we could open a separate ticket to add them.

comment:6 by Tim Graham, 9 years ago

Has patch: unset

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

comment:7 by Alasdair Nicol, 9 years ago

Has patch: set

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.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In dac075e:

Refs #26479 -- Documented is/is not if tag operator behavior for nonexistent variables.

comment:9 by Tim Graham, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top