Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13276 closed (duplicate)

load and include evaluated before if

Reported by: onelson Owned by: nobody
Component: Template system Version: 1.2-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I stumbled into this, have a work-around for my specific case, but am wondering if this is expected behavior or not.

{% if someapp %} <!-- False if someapp is not in INSTALLED_APPS, else True -->
  {% load template_tags_from_someapp %} <!-- throws uncaught exception if "someapp" is False -->
  {% someapp_tag_foo %}
{% endif %}

Likewise, if I separate my app specific code into yet another template:

<!-- in my view's main template -->
{% if someapp %} <!-- False if someapp is not in INSTALLED_APPS, else True -->
  {% include 'someapp_sepecific/extras.html' %}
{% endif %}
<!-- in someapp_specific/extras.html -->
{% load template_tags_from_someapp %} <!-- throws uncaught exception if "someapp" is False -->
{% someapp_tag_foo %}

Obviously there are many ways to skin a cat, but I'm actually hoping this is "fixed" at some point as it will reduce the number of views I'd have to write greatly (allowing me to lean more heavily on the generic views system).

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12064.

comment:2 Changed 4 years ago by onelson

Ahh, great. I don't know how many ways I google'd for this - don't think I would have been able to find #12064 on my own. Thanks!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.