title: How to logout in django?
body: <p>html code</p>
  
  <pre><code>{% if request.user %}
      &lt;a href="{% url 'main:logout' %}"&gt;
          Выход
      &lt;/a&gt;
  {% else %}
      &lt;a href="{% url 'main:registration' %}"&gt;
          Регистрация
      &lt;/a&gt;
  {% endif%}    
  </code></pre>
  
  <p>settings.py</p>
  
  <pre><code>LOGIN_REDIRECT_URL = 'main/index'
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def logout(request):
      logout(request)
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from django.conf.urls import url
  from . import views
  from django.conf import settings
  
  urlpatterns = [
      url(r'^logout/$', views.logout, {'next_page': settings.LOGOUT_REDIRECT_URL}, name='logout')
  ]
  </code></pre>
  
  <p>what's wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/h4fFz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/h4fFz.png" alt="enter image description here"></a></p>