Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
comparar variables forloop con un número
 <ul class="navbar-nav mr-auto"> <li class="nav-item"> <a class="nav-link" href="/">Home </a> </li> <li class="nav-item"> <a class="nav-link" href="{% url 'store' %}">Products</a> </li> {% for x in cat %} <li class="nav-item"> <a class="nav-link" href="#">{{x.name}}</a> </li> {% if forloop.counter >3%} <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">More</a> <div class="dropdown-menu"> <a class="dropdown-item" href="#">{{x.name}}</a> </div> </li> {% endif %} {% endfor %} </ul>

Entonces, lo que quiero aquí es que los objetos en el contador de bucle for sean más de tres, entonces todos deberían aparecer en el menú desplegable que, sin embargo, no funciona a partir de ahora y me da este error. ¿Cuál es la mejor manera de manejar este problema?

 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
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Intenta agregar espacios

 {% if forloop.counter > 3 %}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!