Home > Net >  comparing forloop variables to a number
comparing forloop variables to a number

Time:12-11

 <ul >
            <li >
              <a  href="/">Home </a>
            </li>
            <li >
              <a  href="{% url 'store' %}">Products</a>
            </li>
            {% for x in cat %}
            <li >
              <a  href="#">{{x.name}}</a>
            </li>
            {% if forloop.counter >3%}
            <li >
              <a  data-toggle="dropdown" href="#">More</a>
              <div >
                <a  href="#">{{x.name}}</a>
                
              </div>
            </li>
            {% endif %}

            {% endfor %}
          
            
          </ul>

So what i want here is the objects in the for loop counter be more that three then all should come in the dropdown menu which but it is not working as of now and giving me this error what is the best way to handle this problem

Could not parse the remainder: '>3' from '>3'
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Django Version: 4.0
Exception Type: TemplateSyntaxError
Exception Value:    
Could not parse the remainder: '>3' from '>3'
Exception Location: C:\Users\saran\OneDrive\Desktop\e-com-test\core\hienv\lib\site-packages\django\template\base.py, line 692, in __init__
Python Executable:  C:\Users\saran\OneDrive\Desktop\e-com-test\core\hienv\Scripts\python.exe
Python Version: 3.9.6
Python Path:    
['C:\\Users\\saran\\OneDrive\\Desktop\\e-com-test\\core',
 'C:\\Users\\saran\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
 'C:\\Users\\saran\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
 'C:\\Users\\saran\\AppData\\Local\\Programs\\Python\\Python39\\lib',
 'C:\\Users\\saran\\AppData\\Local\\Programs\\Python\\Python39',
 'C:\\Users\\saran\\OneDrive\\Desktop\\e-com-test\\core\\hienv',
 'C:\\Users\\saran\\OneDrive\\Desktop\\e-com-test\\core\\hienv\\lib\\site-packages']
Server time:    Fri, 10 Dec 2021 13:32:32  0

CodePudding user response:

Try adding spaces

{% if forloop.counter > 3 %}
  • Related