cjahangir
cjahangir

Reputation: 1797

if tag does not works in django template

I have a template. Its quite simple and working fine. but if I use {% if %} tag then the if tag does not works. Instead the if tag works like a string and prints itself in browser. I cant get the cause.

{% verbatim %}
<div ng-if="pageViewing == 'list'" class="gd-content-body transparent gd-cart-checkbox-style">

</div>
<div ng-if="pageViewing == 'grid'" class="gd-content-body transparent gd-cart-checkbox-style">
  <div class="row">
    <article ng-repeat="item in results" resource_id="{{ item.id }}" ng-cloak class="ng-cloak">
      <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">

              <div class="information">
                  <div class="top-content text-center">
                      <div class="title">
                          <a href="{{ item.detail_url }}" title="{{ item.title }}">
                              {{ item.title | limitTo: 45 }}{{ item.title.length  > 45 ? '...' : ''}}
                          </a>
                      </div>
                      <div class="category">
                          {{ item.category__gn_description }}
                          {{ item.category__gn_description == null || item.category__gn_description == '' ? 'Not provided.' : '' }}
                      </div>
                      <div class="details">
                          {{ item.abstract | limitTo: 300 }}{{ item.abstract.length  > 300 ? '...' : ''}}
                      </div>
                      <div>
                          {% if item.title %}
                          {{ item.title }}
                          {% endif %}
                      </div>
                  </div>


              </div>
          </div>

    </article>
      </div>
  </div>

{% endverbatim %}

Upvotes: 0

Views: 252

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600049

You've wrapped the whole thing in {% verbatim %} so Django will never process any of the tags inside it.

Upvotes: 4

Related Questions