2017-03-12 4 views
1

Ich erhalte eine Fehlermeldung, wenn ich auf eine meiner Seiten in meinem Django-Projekt gehe, da das End-Block-Tag ungültig ist (fragt, ob ich mich registriert oder geladen habe). Der Fehler sieht wie folgt aus: enter image description here Mein Code für diese Vorlage - (login.html) - ist unten:Ungültiger Endblock-Tag in Django

{% extends "learning_logs/base.html" %} 

{% block content %} 

    {% if form.errors %} 
    <p>Your username and password didn't match. Please try again.'</p> 
    {% endif %} 

    <form method="post" action="{% url 'users:login' %}"> 
    {% csrf_token %} 
    {{ form.as_p }} 

    <button name="sumbit">log in</button> 
    <input type="hidden" name="next" value="{% extends 'learning_logs/index.html' %}" /> 
    </form> 

{% endblock content %} 

Ich bin sehr verwirrt, und ich frage mich, ob jemand weiß, was das Problem ist? Dank
Milo

Antwort

2
<input type="hidden" name="next" value="{% extends 'learning_logs/index.html' %}" /> 

Above Zeile enthält {% extends .... %}. Um zu verhindern, als extends Tag interpretiert werden, verwenden Sie templatetag tag:

<input type="hidden" name="next" value="{% templatetag openblock %} extends 'learning_logs/index.html' {% templatetag closeblock %}" /> 
1

Verwendung {% endblock %} statt o f {% endblock content %}

+1

'endblock' akzeptiert einen optionalen Namen für die Lesbarkeit. – falsetru