Reputation: 1
I am trying to utilize Django-bootstrap 5 for my form, after creating the form and everything I rendered my template and here is it.
{% extends "base.html" %}
{% load bootstrap5 %}
{% block content %}
<div class="container">
<h1>Log In</h1>
<form method="POST" class="form">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-primary">login</button>
{% endbuttons %}
{% endblock bootsrap_form %}
</form>
</div>
{% endblock content %}
urls.py
path('login/',auth_views.LoginView.as_view(template_name='account/login.html'),name='login')
But when I run the server I got a template syntax error telling me that its expecting an end block meanwhile I have an endblock already, here is the error:
TemplateSyntaxError at /account/login/
Invalid block tag on line 8: 'bootsrap_form', expected 'endblock'. Did you forget to register or load this tag?
Request Method: GET
Request URL: http://127.0.0.1:8000/account/login/
Django Version: 3.2.4
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag on line 8: 'bootsrap_form', expected 'endblock'. Did you forget to register or load this tag?
and the code returned in the error interface looks like this:
1 {% extends "base.html" %}
2 {% load bootstrap5 %}
3 {% block content %}
4 <div class="container">
5 <h1>Log In</h1>
6 <form method="POST">
7 {% csrf_token %}
8 {% bootsrap_form form%}
9 <input type="submit" class="btn btn-default" value="Login">
10 </form>
11
12 </div>
13
14 {% endblock content %}
What I noticed: when I ran the server the first time, I made a typo by writing bootstrap as bootstrap and I fixed it since then, but this error keeps on showing me the first code that I have deleted ever since. What I did: Since I noticed that, changed the template name in my views to make sure it rendered template not found and re-run the server, But the worst thing is that the same error showed up again not only that It does not acknowledge the correction I made to the template, rather what it does is just retuning the first template I deleted. Note, I also read the Django-template documentary and it does not solve it.
Upvotes: 0
Views: 601
Reputation: 189
Obviously you have substantial differences between the two templates. This can happen when:
login.html
templates (it may happen) and your view automatically redirects to the wrong one.Last but not least: bootstrap5
is sometimes confusing: there is a huge difference between 4 and 5. If you use a bootstrap5
with a bootstrap4
inspired template, you will get into endless trouble as nothing will work.
Upvotes: 0