Opened 18 years ago

Closed 17 years ago

#1672 closed defect (fixed)

[patch] Template tags ifequal and ifnotequal throw exception if variable does not resolve.

Reported by: evenson@… Owned by: Adrian Holovaty
Component: Template system Version: 0.91
Severity: minor Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

  1. obj is an instance of a django model
  2. utility is a foreign key field in obj with null=True and blank=True.
    {% ifequal obj.get_utility.abbr 'PG&E' %}
    ...
    {% endifequal %}
    

If utility_id is null in the db this throws a VariableDoesNotExist exception that does not get caught. I propose changing this case so ifequal fails and ifnotequal passes. This would be a simple change in django.core.template.defaulttags.IfEqualNode.render().

Attachments (1)

defaulttags.patch (1.0 KB ) - added by Eric Evenson <evenson@…> 18 years ago.

Download all attachments as: .zip

Change History (7)

by Eric Evenson <evenson@…>, 18 years ago

Attachment: defaulttags.patch added

comment:1 by Matt McClanahan, 18 years ago

Summary: Template tags ifequal and ifnotequal throw exception if variable does not resolve.[patch] Template tags ifequal and ifnotequal throw exception if variable does not resolve.

Add [patch] to summary

comment:2 by Adrian Holovaty, 18 years ago

Status: newassigned

comment:3 by Adrian Holovaty, 18 years ago

This seems to be a problem with resolve_variable rather than ifequal. This unit test confirms the bug:

'ifequal11': ("{% ifequal a.method3.foo 'bar' %}yes{% else %}no{% endifequal %}", {'a': SomeClass()}, 'no'),

comment:4 by Chris Beaven, 17 years ago

Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:5 by Matt McClanahan <cardinal@…>, 17 years ago

Version: SVN0.91

This issue was resolved prior to 0.95.

comment:6 by Chris Beaven, 17 years ago

Resolution: fixed
Status: assignedclosed

Thanks Matt, let's just mark it as closed then.

Note: See TracTickets for help on using tickets.
Back to Top