I have the following code in a base.html file in a Django project's header area.
{% if user.is_authenticated %}
<a class="nav-item nav-link" href="{% url 'create' %}"><span class="oi oi-plus"></span></a>
<a class="nav-item nav-link" href="javascript:{document.getElementById('logout').submit()}" onclick="">Logout</a>
<form id="logout" method="POST" action="{% url 'logout' %}">
{% csrf_token %}
<input type="hidden" />
</form>
{% else %}
<a class="nav-item nav-link" href="{% url 'signup' %}">Sign Up</a>
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a>
{% endif %}
I try to comment out the Javascript area "{% url 'create' %}" but it is not working (the error appears because the 'create' code chunks don't yet exists):
<a class="nav-item nav-link" href="/*{% url 'create' %}*/"><span class="oi oi-plus"></span></a>
<!-- <a class="nav-item nav-link" href="{% url 'create' %}"><span class="oi oi-plus"></span></a> -->
<!-- <a class="nav-item nav-link" href="/*{% url 'create' %}*/"><span class="oi oi-plus"></span></a> -->
When I delete the whole line the error disappears. What I would be interested is how to keep it as a comment so later on when I implement that area I can uncomment it.
You have two solutions.
For a code block use:
{% comment %}...{% endcomment %}
For single line you can use this:
{# some text #}