Opened 7 years ago

Closed 14 months ago

#12212 closed Bug (fixed)

inclusion_tag behavior on variable not in context is inconsistent

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

Description

If you use a variable that doesn't exist in the context as an argument to a template tag created with @register.inclusion_tag() the tag throws a VariableDoesNotExist which is inconsistent with the way that all other tags behave in the template language.

I would expect that the wrapping inclusion_tag() code just passes None to the wrapped templatetag for the argument rather than blowing up.

Attachments (1)

12212.patch (5.6 KB) - added by Leo Shklovskii 7 years ago.
Patch against r12699

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

Changed 7 years ago by Leo Shklovskii

Attachment: 12212.patch added

Patch against r12699

comment:2 Changed 7 years ago by Leo Shklovskii

Has patch: set
milestone: 1.2
Owner: changed from nobody to Leo Shklovskii
Status: newassigned

There's two ways I could see of solving this: document the fact that they do this or fix the behavior. The former is relatively simple if the core committers decide its better so the attached patch does the latter.

Along the way I noticed that simple_tag has the same issue and fixed it as well. The patch includes doc changes and sets up tests for simple_tag and inclusion_tag.

Adding this for consideration into 1.2.

comment:3 Changed 7 years ago by Russell Keith-Magee

milestone: 1.21.3

Not critical for 1.2.

comment:4 Changed 6 years ago by Matt McClanahan

milestone: 1.3
Severity: Normal
Type: Bug

comment:5 Changed 6 years ago by patchhammer

Easy pickings: unset
Patch needs improvement: set

12212.patch fails to apply cleanly on to trunk

comment:6 Changed 5 years ago by Leo Shklovskii

Owner: Leo Shklovskii deleted
Status: assignednew
UI/UX: unset

comment:7 Changed 5 years ago by Leo Shklovskii

milestone: 1.4

comment:8 Changed 5 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

comment:9 Changed 14 months ago by Tim Graham

Resolution: fixed
Status: newclosed

I tested as far back as Django 1.4 and {% custom_tag nonexistent %} passes an empty string for nonexistent to the tag so it seems this has been fixed unless I misunderstood the issue.

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