Django template -TemplateSyntaxError

I am a beginner in Django world. When I try render my login.html template I'm facing this problem even there is a closing block.

TemplateSyntaxError at /login/ Invalid block tag on line 12: 'else', expected 'endblock'. Did you forget to register or load this tag?`

Here is my template

{% extends 'base.html' %} 
{% block content %} 
{% if not request.user.is_authenticated %}
<div style="margin-top: 30px">
  <form method="POST">
    {% csrf_token %} {% if error %}
    <p style="color: red">{{error}}</p>
    {% endif %}
      <input type="text" name="username" placeholder="username" />
      <input type="password" name="password" placeholder="password" />
    <button type="submit">Login</button>

{% else %}

  You're already logged in. Would you like to <a href="/logout/"> logout?</a>
{% endif %} 

{% endblock content%}

Back to Top