M
M
maximoto1232020-12-20 21:28:53
Template Engines
maximoto123, 2020-12-20 21:28:53

How to fix this condition: {% if i.id%2 != 0 %}, to display the template?

TemplateSyntaxError: Could not parse the remainder: '%2' from 'i.id%2'. Tell me. Where is the mistake?

Code example:

<div class="page-section portfolio-page">
    <div class="portfolio-section">
        <div class="row">

            {% for i in photo_index %}
                {% if i.id%2 != 0 %}
            <div class="col-xl-4">
                <div class="portfolio-item">
                    <img src="{{ i.photo.url }}" alt="#">
                    <div class="pi-info">
                        <h5>{{ i.title }}</h5>
                        <a href="{% url 'photo' i.pk %}"><img src="{% static 'img/arrow-righ-3.png' %}" alt=""></a>
                {% else %}
                        <div class="col-xl-8">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="portfolio-item">
                                        <img src="{% i.photo.url %}" alt="#">
                                        <div class="pi-info">
                                            <h5>{{ i.title }}</h5>
                                            <a href="{% url 'photo' i.pk %}"><img
                                                    src="{% static 'img/arrow-right.png' %}" alt=""></a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {% endif %}
            {% endfor %}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question