title: {% extends "base.html" %} and {% block content %} inside if statement (Django app)
body: <p>In a Django template, I want to show different things to authenticated and unauthenticated users. </p>
  
  <p>Specifically, something like the following:</p>
  
  <pre><code>{% if not user.is_authenticated %}
      &lt;div class="margin"&gt;
      {{ group.topic }}
      &lt;/div&gt;
  {% else %}
      {% extends "base.html" %}
      {% load humanize %}
      {% block content %}
      &lt;div class="margin"&gt;
          {{ group.topic }}
          &lt;br&gt;
          &lt;b&gt;members:&lt;/b&gt;
              {% for member in members %}
              &lt;a href="{% url 'profile' slug=member.username %}"&gt;{{ member.username }}&lt;/a&gt;,&amp;nbsp;
              {% endfor %}
          &lt;hr size=1&gt;
          &lt;form action="{% url 'private_group_reply' slug=unique %}" method="POST" enctype="multipart/form-data"&gt;
              {% csrf_token %}
              &lt;input type="hidden" id="id_link" name="unique" class="hidden_id" value="{{ unique }}"&gt;
              &lt;br&gt;{{ form.image }}&lt;br&gt;
              &lt;br&gt;{{ form.text }}&lt;br&gt;
              &lt;input class="button" type="submit" value="OK" id="id_submit"&gt;
          &lt;/form&gt;
          {% for reply in replies %}
          {{ reply.writer }}: {{ reply.text }},{{ reply.submitted_on|naturaltime }}&lt;br&gt;
          {% endfor %}
  
      {% endblock %}
  {% endif %}
  </code></pre>
  
  <p>In other words, I want to extend base.html only for authenticated users, for non-authenticated ones, I want to have a plain template. </p>
  
  <p>I keep getting a <strong>TemplateSyntaxError: invalid block tag {% endif %}</strong></p>
  
  <p>How can I accomplish this? </p>
  
  <p><em>The app in question is a legcy Django app, using Django 1.5</em>.</p>