Opened 3 years ago

Closed 3 years ago

#33370 closed Uncategorized (invalid)

{% if %} tag incorreclty being evaluated

Reported by: Michael Owned by: nobody
Component: Template system Version: 4.0
Severity: Normal Keywords: templatetag
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the below snippet, I actually check {% if DEBUG %}, but just to prove the result is Falsey:

{% load cache %}

{% if False %}
    {% cache None user.email user.first_name %}
{% endif %}
Here's some content I don't wish to cache when DEBUG is on.
{% if False %}
    {% endcache %}
{% endif %}

The error generated is:

Invalid block tag on line 28: 'endif', expected 'endcache'. Did you forget to register or load this tag?

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

Beginning ({% cache %}) and ending ({% endcache %}) of tags cannot live in separate {% if %} blocks.

If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.

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