0

I try to do this:

  {% for post in posts %}
  {% if forloop.counter 15>=30  %}
    <div style="background-color: #9999;" class="card mb-3" style="max-width: 100%;">
      <div class="row no-gutters">
        <div class="col-md-4">
          <a href="{% url 'post_detail' post.slug %}"><img style="height: 200px; width: 330px;" src="{{ post.mainimage.url }}" class="card-img" alt="..."></a>
        </div>
        <div class="col-md-6" id="ph">
          <div class="card-body">
            <h5 class="card-title">{{ post.title }} , {{ post.xnumber }}</h5>
            <p class="card-text">{{ post.version }}</p>
            <p>{{ post.category }}</p>
            <p class="card-text"><small class="text-muted">{{ post.date_added }}</small></p>
          </div>
        </div>
      </div>
    </div>
  <hr >
  {% endif %}
    {% endfor %}

and it gives me an error: the photo here

**What I'm trying to do is make the repetition start at 15 and end or = at 30 **

I searched a lot and couldn't find what I wanted So please help me lan = python django

Dani Mesejo
  • 61,499
  • 6
  • 49
  • 76
7mood
  • 5
  • 5
  • Does this answer your question? [Numeric for loop in Django templates](https://stackoverflow.com/questions/1107737/numeric-for-loop-in-django-templates) – Marat Nov 03 '21 at 22:09
  • you can compare forloop.counter like this ==> `forloop.counter>15 and forloop.counter<=30 ` in you for loop thats it. – Shreeyansh Jain Nov 04 '21 at 03:52

1 Answers1

0

try it like this

{% if forloop.counter>15 and forloop.counter<=30  %}
taha maatof
  • 1,862
  • 2
  • 9
  • 23