Got the following error on pressing Logout Button with the code at bottom-
ValueError at /logout
The view app.views.logout didn't return an HttpResponse object. It returned None instead.
Request Method: GET
Request URL: http://127.0.0.1:8000/logout
Django Version: 3.0.8
Exception Type: ValueError
Exception Value:
The view app.views.logout didn't return an HttpResponse object. It returned None instead.
my code is
def logout(request):
if request.method=="POST":
auth.logout(request)
return redirect('login')
my html is
<li class="nav-item mr-3">
<form id="logout" method="POST">
{% csrf_token %}
<input type ="hidden">
</form>
<a class="nav-link" href="{% url 'logout'%}" onclick="javacript:document.getElementById('logout').submit()">
Logout
</a>
</li>