pythondjangodjango-templatesdjango-errors

Is django broken? I keep getting this error while nothing is wrong "Invalid block tag : 'endif'. Did you forget to register or load this tag?"


Hi everyone please i keep getting this error "Invalid block tag : 'endif'. Did you forget to register or load this tag?" from my code, i have gone over the code severally and still can't figure out what the problem is

<nav id="navbar" class="navbar">
      <ul>
        {% if request.path == '/' or 'home' in request.path or 'contact' in
        request.path or 'login' in request.path or 'signup' in request.path %}
        <li>
          <a class="nav-link scrollto active" href="{% url 'home' %}">Home</a>
        </li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#about">About</a>
        </li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#services">Services</a>
        </li>
        <li><a href="{% url 'home' %}#blog">Blog</a></li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#contact"
            >Contact</a>
        </li>
        {% if not user.is_authenticated %}
        <li>
          <a class="getstarted scrollto" href="{% url 'account_signup' %}"
            >Get Started</a>
        </li>
        {% else %}
        <li></li>
        {% endif %} {% elif request.path == '/' and not
        request.user.is_authenticated or request.path == 'home' and not
        request.user.is_authenticated or request.path == 'contact' and not
        request.user.is_authenticated %}

        <li>
          <a class="nav-link scrollto active" href="{% url 'home' %}">Home</a>
        </li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#about">About</a>
        </li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#services"
            >Services</a>
        </li>
        <li><a href="{% url 'home' %}#blog">Blog</a></li>
        <li>
          <a class="nav-link scrollto" href="{% url 'home' %}#contact"
            >Contact</a>
        </li>
        <li>
          <a class="getstarted scrollto" href="{% url 'home' %}#about"
            >Get Started</a>
        </li>
        {% endif %}
      </ul>
      <i class="bi bi-list mobile-nav-toggle"></i>
    </nav>

I have tried removing the affected endif and rewritting it slowly to make sure i didn't make a mistake, I have also checked if the the if statement i am closing has any errors like an unnecessary whitespace between the { and % but couldn't find any


Solution

  • I realized it was my code formatter (prettier) that was messing up the code so all I had to do was change the formatter and I stopped getting the error