Opened 10 years ago
Closed 10 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 , 10 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 10 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 10 years ago
| Has patch: | set |
|---|
comment:5 by , 10 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → new |
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 , 10 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 , 10 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:9 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Pull request https://github.com/django/django/pull/6436/files