HTML代碼如何在django註銷?
{% if request.user %}
<a href="{% url 'main:logout' %}">
Выход
</a>
{% else %}
<a href="{% url 'main:registration' %}">
Регистрация
</a>
{% endif%}
settings.py
LOGIN_REDIRECT_URL = 'main/index'
views.py
def logout(request):
logout(request)
urls.py
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')
]
有什麼不對?
請不要在截圖中發佈代碼(或回溯)。它們不能被搜索或複製,並且可用性差。相反,將其作爲文本直接粘貼到您的問題中。如果選擇它並單擊'{}'按鈕或Ctrl + K,則代碼塊將縮進四個空格,這將導致它被呈現爲代碼。 – Chris