Python - Panel
// views.py inside APP folder
def logout(request):
if request.method == 'POST':
auth.logout(request)
messages.success(request, 'You are successfully logged out')
return redirect('login')
// topbar.html paste code below
<ul class="top-social-media pull-right">
{% if user.is_authenticated %}
<li>
<a href="{% url 'dashboard'%}" class="sign-in"><i class="fa fa-tachometer"></i> Dashboard</a>
</li>
<li>
<a href="javascript:{document.getElementById('logout').submit()}" class="sign-out"><i class="fa fa-sign-out"></i> Logout</a>
<form action="{% url 'logout' %}" method="POST" id="logout">
{% csrf_token %}
<input type="hidden">
</form>
</li>
{% else %}
<li>
<a href="{% url 'login'%}" class="sign-in"><i class="fa fa-sign-in"></i> Login</a>
</li>
<li>
<a href="{% url 'register' %}" class="sign-in"><i class="fa fa-user"></i> Register</a>
</li>
{% endif %}
</ul>
BenLeolam