Opened 7 years ago

Closed 10 months ago

#12212 closed Bug (fixed)

inclusion_tag behavior on variable not in context is inconsistent

Reported by: Leo 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


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 6 years ago.
Patch against r12699

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by Leo

Patch against r12699

comment:2 Changed 6 years ago by Leo

  • Has patch set
  • milestone set to 1.2
  • Owner changed from nobody to Leo
  • Status changed from new to assigned

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 6 years ago by russellm

  • milestone changed from 1.2 to 1.3

Not critical for 1.2.

comment:4 Changed 5 years ago by mattmcc

  • milestone 1.3 deleted
  • Severity set to Normal
  • Type set to Bug

comment:5 Changed 5 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

  • Owner Leo deleted
  • Status changed from assigned to new
  • UI/UX unset

comment:7 Changed 5 years ago by Leo

  • milestone set to 1.4

comment:8 Changed 5 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

comment:9 Changed 10 months ago by timgraham

  • Resolution set to fixed
  • Status changed from new to closed

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