Django 'block' tag called 'content' appears more than once

I got this error while creating the application, and I think the problem is in my login.html as it points to the error sheet. Is it because I have 2 {% block content%} that it conflicts with? Thanks for helping me.

TemplateSyntaxError at /login/ 'block' tag with name 'content' appears more than once Request Method: GET Request URL: http://127.0.0.1:8000/login/ Django Version: 1.4.3 Exception Type: TemplateSyntaxError Exception Value: 'block' tag with name 'content' appears more than once Error during template rendering In template C:\djcode\mysite\drinker\templates\login.html, error at line 21 'block' tag with name 'content' appears more than once 11 <div class="register_div"> 12 {% if form.password.errors %}<p class="error">{{ form.password.errors }}</p>{% endif %} 13 <p><label for="password"{% if form.password.errors %} class="error"{% endif %}>Password:</label></p> 14 <p>{{ form.password }}</p> 15 </div> 16 <p><input type="submit" alt="register" /></p> 17 </form> 18 <p>Forgot your password? <a href="/resetpassword/">Reset it!</a></p> 19 {% endblock %} 20 {% extends "base.html" %} 21 {% block content %} 

My login.html

  {% extends "base.html" %} {% block content %} <form action="" method="post"> {% csrf_token %} {% if form.errors %}<p>Please correct the following fields:</p>{% endif %} <div class="register_div"> {% if form.username.errors %}<p class="error">{{ form.username.errors }}</p>{% endif %} <p><label for="username"{% if form.username.errors %} class="error"{% endif %}>Username:</label></p> <p>{{ form.username }}</p> </div> <div class="register_div"> {% if form.password.errors %}<p class="error">{{ form.password.errors }}</p>{% endif %} <p><label for="password"{% if form.password.errors %} class="error"{% endif %}>Password:</label></p> <p>{{ form.password }}</p> </div> <p><input type="submit" alt="register" /></p> </form> <p>Forgot your password? <a href="/resetpassword/">Reset it!</a></p> {% endblock %} 

I also have a trace associated with my view.py

  Traceback Switch to copy-and-paste view C:\Python26\Lib\site-packages\django\core\handlers\base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ... β–Ά Local vars C:\djcode\mysite\drinker\views.py in LoginRequest return render_to_response('login.html', context, context_instance=RequestContext(request)) ... β–Ά Local vars 
+4
source share
1 answer

Yes, the error is pretty clear: you have two blocks called "content".

Honestly, I can’t understand what you are doing, as the second block seems to be an exact duplicate of the first. You also cannot have two extends tags.

+2
source

All Articles